added integration to save the employee data in employeelist page
This commit is contained in:
parent
c2c5ef0ff0
commit
0af402c018
22
db.json
22
db.json
@ -48,6 +48,28 @@
|
||||
"firstname": "gajanan",
|
||||
"lastname": "bodke",
|
||||
"email": "gajanan001@gmail.com"
|
||||
},
|
||||
{
|
||||
"id": "4db0",
|
||||
"firstname": "sachin",
|
||||
"lastname": "patil",
|
||||
"age": "22",
|
||||
"gender": "",
|
||||
"email": "sachin@gmail.com",
|
||||
"mobile": "07559393995",
|
||||
"address": {
|
||||
"address_line_1": "",
|
||||
"address_line_2": "",
|
||||
"nearby_landmark": "",
|
||||
"pincode": "",
|
||||
"city_id": ""
|
||||
},
|
||||
"image": null,
|
||||
"address.address_line_1": "Sarovar line 1 , Bavdhan, Pune",
|
||||
"address.address_line_2": "LOCAL :,Bavdhan",
|
||||
"address.pincode": "411021",
|
||||
"address.nearby_landmark": "i",
|
||||
"address.city_id": "1"
|
||||
}
|
||||
],
|
||||
"products": [
|
||||
|
@ -94,11 +94,8 @@ const AddEmployee = () => {
|
||||
});
|
||||
|
||||
try {
|
||||
await axiosInstance.post('http://localhost:5000/employees', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
const data = await createEmployee(employeeData);
|
||||
console.log('Employee added successfully:', data);
|
||||
navigate('/employees');
|
||||
} catch (error) {
|
||||
console.error('Error adding employee:', error.response || error.message);
|
||||
@ -182,79 +179,83 @@ const AddEmployee = () => {
|
||||
className={CLASSES.formInput}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={CLASSES.formGroup}>gender:</label>
|
||||
<select
|
||||
name="gender"
|
||||
value={employeeData.gender}
|
||||
|
||||
<div className={CLASSES.formGroup}>
|
||||
<label htmlFor="email">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
id="email"
|
||||
name="email"
|
||||
className={CLASSES.formInput}
|
||||
value={employeeData.email}
|
||||
onChange={handleInputChange}
|
||||
className={CLASSES.formSelect}
|
||||
>
|
||||
<option value="" disabled>select gender</option>
|
||||
<option value="male">male</option>
|
||||
<option value="female">female</option>
|
||||
<option value="other">other</option>
|
||||
</select>
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={CLASSES.formGroup}>mobile:</label>
|
||||
<div className={CLASSES.formGroup}>
|
||||
<label htmlFor="mobile">Mobile Number</label>
|
||||
<input
|
||||
type="text"
|
||||
id="mobile"
|
||||
name="mobile"
|
||||
className={CLASSES.formInput}
|
||||
value={employeeData.mobile}
|
||||
onChange={handleInputChange}
|
||||
className={CLASSES.formInput}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={CLASSES.formGroup}>address line 1:</label>
|
||||
<div className={CLASSES.formGroup}>
|
||||
<label htmlFor="address_line_1">Address Line 1</label>
|
||||
<input
|
||||
type="text"
|
||||
name="address_line_1"
|
||||
id="address_line_1"
|
||||
name="address.address_line_1"
|
||||
className={CLASSES.formInput}
|
||||
value={employeeData.address.address_line_1}
|
||||
onChange={handleInputChange}
|
||||
className={CLASSES.formInput}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={CLASSES.formGroup}>address line 2:</label>
|
||||
<div className={CLASSES.formGroup}>
|
||||
<label htmlFor="address_line_2">Address Line 2</label>
|
||||
<input
|
||||
type="text"
|
||||
name="address_line_2"
|
||||
id="address_line_2"
|
||||
name="address.address_line_2"
|
||||
className={CLASSES.formInput}
|
||||
value={employeeData.address.address_line_2}
|
||||
onChange={handleInputChange}
|
||||
className={CLASSES.formInput}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={CLASSES.formGroup}>nearby landmark:</label>
|
||||
<div className={CLASSES.formGroup}>
|
||||
<label htmlFor="nearby_landmark">Nearby Landmark</label>
|
||||
<input
|
||||
type="text"
|
||||
name="nearby_landmark"
|
||||
id="nearby_landmark"
|
||||
name="address.nearby_landmark"
|
||||
className={CLASSES.formInput}
|
||||
value={employeeData.address.nearby_landmark}
|
||||
onChange={handleInputChange}
|
||||
className={CLASSES.formInput}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={CLASSES.formGroup}>pincode:</label>
|
||||
<div className={CLASSES.formGroup}>
|
||||
<label htmlFor="pincode">Pincode</label>
|
||||
<input
|
||||
type="text"
|
||||
name="pincode"
|
||||
id="pincode"
|
||||
name="address.pincode"
|
||||
className={CLASSES.formInput}
|
||||
value={employeeData.address.pincode}
|
||||
onChange={handleInputChange}
|
||||
className={CLASSES.formInput}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={CLASSES.formGroup}>city:</label>
|
||||
<div className={CLASSES.formGroup}>
|
||||
<label htmlFor="city_id">City</label>
|
||||
<select
|
||||
name="city_id"
|
||||
id="city_id"
|
||||
name="address.city_id"
|
||||
className={CLASSES.formSelect}
|
||||
value={employeeData.address.city_id}
|
||||
onChange={handleInputChange}
|
||||
className={CLASSES.formSelect}
|
||||
>
|
||||
<option value="" disabled>select city</option>
|
||||
<option value="">Select City</option>
|
||||
{cities.map((city) => (
|
||||
<option key={city.id} value={city.id}>
|
||||
{city.name}
|
||||
@ -262,6 +263,7 @@ const AddEmployee = () => {
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" className={CLASSES.submitButton}>
|
||||
add employee
|
||||
</button>
|
||||
|
@ -61,7 +61,7 @@ const AdminSidebar = () => {
|
||||
<Link to="/employees" className={classNames.iconLink}>
|
||||
<img src={EmployeeIcon} alt="Employee" className={classNames.icon} />
|
||||
</Link>
|
||||
<Link to="/admin/measurements" className={classNames.iconLink}>
|
||||
<Link to="/setmeasurements" className={classNames.iconLink}>
|
||||
<img src={MeasurmentsIcon} alt="Measurements" className={classNames.icon} />
|
||||
</Link>
|
||||
<Link to="/admin/profile" className={classNames.iconLink}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user