diff --git a/client/src/pages/Designers/index.jsx b/client/src/pages/Designers/index.jsx index 981e0a2..b698b13 100644 --- a/client/src/pages/Designers/index.jsx +++ b/client/src/pages/Designers/index.jsx @@ -1,11 +1,149 @@ -import React from 'react' - +import React from "react"; +import toast from "react-hot-toast"; +import axios from "axios"; const Designer_home = () => { - return ( -
- inside designers home -
- ) -} - -export default Designer_home + const [formData, setFormData] = React.useState({ + Portfolio: "", + message: "", + }); + + function handleChange(event) { + const { name, value, type, checked } = event.target; + setFormData((prevFormData) => { + return { + ...prevFormData, + [name]: type === "checkbox" ? checked : value, + }; + }); + } + async function handleSubmit(event) { + event.preventDefault(); + try { + console.log(formData); + const { data } = await axios.post( + "http://localhost:3000/api/users/designer", + { + description: formData.message, + portfoliolink: formData.Portfolio, + }, + { + headers: { + "Content-Type": "application/json", + }, + withCredentials: true, + } + ); + toast(data.message); + window.location.href = "/"; + } catch (error) { + toast.error(error.response.data.message); + // console.error(error); + } + + } + + return ( +
+
+
+
+
+
+

+ Wassup!
Let's get in touch +

+
+
+ + +
+
+ + + +
+
+ +
+
+
+ +
+
+

+ Drop in our office +

+

+ We would love to have you drop by our office! + Your presence and energy would truly brighten up + our day. Looking forward to seeing you soon! +

+ +
+
+ +
+
+

Main Office

+

+ B-401, Hall of Residance 4, IIITDMJ PIN- + 482005 +

+
+
+ +
+
+ +
+
+

Call Us

+

+ Tel: 90799-15245 +

+

+ Fax: 88698-87160 +

+
+
+
+
+
+
+
+ ); +}; + +export default Designer_home; diff --git a/client/src/pages/Retailer-home/index.jsx b/client/src/pages/Retailer-home/index.jsx index 66a1c89..b657b1f 100644 --- a/client/src/pages/Retailer-home/index.jsx +++ b/client/src/pages/Retailer-home/index.jsx @@ -1,69 +1,11 @@ -import React from 'react' +import React from "react"; const Retailer_home = () => { - return ( -
-
-
-
-

Customise Now

-

Form is mobile responsive. Give it a try.

- -
-
-
-

Personal Details

-

Please fill out all the fields.

-
- -
-
- -
- - -
- -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- - -
-
- -
-
- -
-
+ return ( +
+
-
-
-
-
-
- ) -} + ); +}; -export default Retailer_home \ No newline at end of file +export default Retailer_home; diff --git a/server/controllers/user.js b/server/controllers/user.js index b6945ea..4be992e 100644 --- a/server/controllers/user.js +++ b/server/controllers/user.js @@ -65,13 +65,24 @@ const getMyProfile = (req, res) => { const registerdesigner = (req, res) => { const { description, portfoliolink } = req.body; - con.query(`INSERT INTO designer VALUES ('${req.user["email"]}', '${description}', '${portfoliolink}')`, (err, result) => { + con.query(`SELECT * FROM designer WHERE email='${req.user["email"]}'`, (err, result) => { if (err) { throw err; } - return res.status(200).json({ - success: true, - message: "Registered Designer" + if (result.length != 0) { + return res.status(404).json({ + success: false, + message: "Designer already exists." + }); + } + con.query(`INSERT INTO designer VALUES ('${req.user["email"]}', '${description}', '${portfoliolink}')`, (err, result) => { + if (err) { + throw err; + } + return res.status(200).json({ + success: true, + message: "Registered Designer" + }); }) }) }