diff --git a/client/src/pages/Customize/customize.jsx b/client/src/pages/Customize/customize.jsx
index adab57d..91d08ac 100644
--- a/client/src/pages/Customize/customize.jsx
+++ b/client/src/pages/Customize/customize.jsx
@@ -1,4 +1,4 @@
-import React from "react";
+import React, { useEffect } from "react";
import axios from "axios";
import toast from "react-hot-toast";
@@ -6,7 +6,27 @@ const Customize = () => {
const [formData, setFormData] = React.useState({
desc: "",
link: "",
+ shoeModel: "Crocs",
+ shoeSize: "7",
});
+ const [user, setUser] = React.useState(null);
+
+
+ useEffect(() => {
+ const fetchUser = async () => {
+ try {
+ const { data } = await axios.get("http://localhost:3000/api/users/me", {
+ withCredentials: true,
+ });
+ setUser(data.user);
+ } catch (error) {
+ toast.error("Please log in to customize products");
+ window.location.href = "/login";
+ }
+ };
+
+ fetchUser();
+ }, []);
function handleChange(event) {
const { name, value, type, checked } = event.target;
@@ -17,6 +37,7 @@ const Customize = () => {
};
});
}
+
async function handleSubmit(event) {
event.preventDefault();
if (!formData.desc && !formData.link)
@@ -29,6 +50,9 @@ const Customize = () => {
{
description: formData.desc,
image: formData.link,
+ shoeModel: formData.shoeModel,
+ shoeSize: formData.shoeSize,
+ userId: user.email,
},
{
headers: {
@@ -41,9 +65,10 @@ const Customize = () => {
window.location.href = "/";
} catch (error) {
toast.error(error.response.data.message);
- // console.error(error);
+
}
}
+
return (
@@ -67,9 +92,11 @@ const Customize = () => {
Shoe Model