Skip to content

Commit

Permalink
added designer page + server
Browse files Browse the repository at this point in the history
  • Loading branch information
dvjsharma committed Nov 24, 2023
1 parent 8375490 commit fa211b4
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 79 deletions.
158 changes: 148 additions & 10 deletions client/src/pages/Designers/index.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<div>
inside designers home
</div>
)
}

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 (
<div>
<div className="flex justify-center items-center bg-white">
<div className="container mx-auto my-4 px-4 lg:px-20">
<form onSubmit={handleSubmit}>
<div className="w-full p-8 my-4 md:px-12 lg:w-9/12 lg:pl-20 lg:pr-40 mr-auto rounded-2xl shadow-2xl">
<div className="flex">
<h1 className="text-5xl font-serif font-800">
Wassup! <br /> Let's get in touch
</h1>
</div>
<div className="grid grid-cols-1 gap-5 md:grid-cols-2 mt-5">
<input
className="w-full bg-gray-100 text-gray-900 mt-2 p-3 rounded-lg focus:outline-none focus:shadow-outline"
type="text"
placeholder="First Name"
// onChange={handleChange}
// name="firstName"
// value={formData.firstName}
/>
<input
className="w-full bg-gray-100 text-gray-900 mt-2 p-3 rounded-lg focus:outline-none focus:shadow-outline"
type="text"
placeholder="Last Name"
// onChange={handleChange}
// name="lastName"
// value={formData.lastName}
/>
</div>
<div className="my-4 gap-3 flex flex-col">
<input
className="w-full bg-gray-100 text-gray-900 mt-2 p-3 rounded-lg focus:outline-none focus:shadow-outline"
type="text"
placeholder="Portfolio link"
onChange={handleChange}
name="Portfolio"
value={formData.Portfolio}
/>

<textarea
placeholder="Tell us about yourself"
className="w-full h-32 bg-gray-100 text-gray-900 mt-2 p-3 rounded-lg focus:outline-none focus:shadow-outline"
onChange={handleChange}
name="message"
value={formData.message}
></textarea>
</div>
<div className="my-2 w-1/2 lg:w-1/4">
<button
className="text-sm tracking-wide bg-black text-gray-100 p-3 rounded-lg w-full
focus:outline-none focus:shadow-outline"
>
Send Message
</button>
</div>
</div>
</form>

<div className="font-serif w-full lg:-mt-96 lg:w-2/6 px-8 py-12 ml-auto bg-black rounded-2xl">
<div className="flex flex-col text-white">
<h1 className="text-4xl my-4">
Drop in our office
</h1>
<p className="text-gray-400">
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!
</p>

<div className="flex my-4 w-2/3 lg:w-1/2">
<div className="flex flex-col">
<i className="fas fa-map-marker-alt pt-2 pr-2" />
</div>
<div className="flex flex-col">
<h2 className="text-2xl">Main Office</h2>
<p className="text-gray-400">
B-401, Hall of Residance 4, IIITDMJ PIN-
482005
</p>
</div>
</div>

<div className="flex my-4 w-2/3 lg:w-1/2">
<div className="flex flex-col">
<i className="fas fa-phone-alt pt-2 pr-2" />
</div>
<div className="flex flex-col">
<h2 className="text-2xl">Call Us</h2>
<p className="text-gray-400">
Tel: 90799-15245
</p>
<p className="text-gray-400">
Fax: 88698-87160
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};

export default Designer_home;
72 changes: 7 additions & 65 deletions client/src/pages/Retailer-home/index.jsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,11 @@
import React from 'react'
import React from "react";

const Retailer_home = () => {
return (
<div>
<div className="min-h-screen p-6 bg-gray-100 flex items-center justify-center">
<div className="container max-w-screen-lg mx-auto">
<div>
<h2 className="font-semibold text-xl text-gray-600">Customise Now</h2>
<p className="text-gray-500 mb-6">Form is mobile responsive. Give it a try.</p>

<div className="bg-white rounded shadow-lg p-4 px-4 md:p-8 mb-6">
<div className="grid gap-4 gap-y-2 text-sm grid-cols-1 lg:grid-cols-3">
<div className="text-gray-600">
<p className="font-medium text-lg">Personal Details</p>
<p>Please fill out all the fields.</p>
</div>

<div className="lg:col-span-2">
<div className="grid gap-4 gap-y-2 text-sm grid-cols-1 md:grid-cols-5">

<div className="md:col-span-5">
<label for="retailer_name">Name</label>
<input type='text' name="retailer_name" id="retailer_name" className="h-10 border mt-1 rounded w-full bg-gray-50 " />
</div>

<div className="md:col-span-5">
<label for="retailer_locality">Locality</label>
<input type='text' name="retailer_locality" id="retailer_locality" className="h-10 border mt-1 rounded w-full bg-gray-50 " />
</div>
<div className="md:col-span-5">
<label for="retailer_city">City</label>
<input type='text' name="retailer_city" id="retailer_city" className="h-10 border mt-1 rounded w-full bg-gray-50 " />
</div>
<div className="md:col-span-5">
<label for="retailer_state">State</label>
<input type='text' name="retailer_state" id="retailer_state" className="h-10 border mt-1 rounded w-full bg-gray-50 " />
</div>
<div className="md:col-span-5">
<label for="retailer_country">Country</label>
<input type='text' name="retailer_country" id="retailer_country" className="h-10 border mt-1 rounded w-full bg-gray-50 " />
</div>
<div className="md:col-span-5">
<label for="retailer_distributor">Distributor</label>
<select name="retailer_distributor" id="retailer_distributor" className="h-10 border mt-1 rounded px-4 w-full bg-gray-50">
<option>Crocs</option>
<option>Adidas</option>
</select>
</div>


<div className="md:col-span-5 text-right">
<div className="inline-flex items-end">
<button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Submit</button>
</div>
</div>

</div>
</div>
return (
<div>

</div>
</div>
</div>
</div>
</div>
</div>
)
}
);
};

export default Retailer_home
export default Retailer_home;
19 changes: 15 additions & 4 deletions server/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
})
})
}
Expand Down

0 comments on commit fa211b4

Please sign in to comment.