Skip to content

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
KirtanTank committed Aug 18, 2024
1 parent 9287588 commit 4ab98cf
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions components/AddVendor.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { useSession } from 'next-auth/react';
import { useSession } from "next-auth/react";

const AddVendor = () => {
const [formData, setFormData] = useState({
Expand Down Expand Up @@ -58,9 +58,24 @@ const AddVendor = () => {
};

// Send Data to Server
AddNewVendor(VendorPayload);

setFormData({
name: "",
bankName: "",
accNo: "",
address1: "",
address2: "",
city: "",
zipCode: "",
country: "",
});
};

const AddNewVendor = async (formData) => {
await fetch(`/api/addVendors`, {
method: "POST",
body: JSON.stringify(VendorPayload),
body: JSON.stringify(formData),
headers: {
"Content-type": "application/json; charset=UTF-8",
},
Expand All @@ -76,17 +91,6 @@ const AddVendor = () => {
console.log("Error: ", err);
toast("Sorry, could not create vendor", { type: "error" });
});

setFormData({
name: "",
bankName: "",
accNo: "",
address1: "",
address2: "",
city: "",
zipCode: "",
country: "",
});
};

return (
Expand Down

0 comments on commit 4ab98cf

Please sign in to comment.