From dddd1b7ea2466f74c7b738391a0e0d226fd483e5 Mon Sep 17 00:00:00 2001 From: surajb Date: Thu, 18 Jul 2024 15:14:17 +0530 Subject: [PATCH] changes done in Addemployee page and AddCustomer page --- db.json | 28 +++++ src/components/admin/AddEmployee.jsx | 102 +++++++++++++--- src/components/customer/AddCustomer.jsx | 142 ++++++++++++++++------- src/components/customer/CustomerList.jsx | 2 +- src/components/sidebar/AdminSidebar.jsx | 4 +- 5 files changed, 218 insertions(+), 60 deletions(-) diff --git a/db.json b/db.json index 873cc9b..643c579 100644 --- a/db.json +++ b/db.json @@ -28,6 +28,20 @@ "id": "1", "name": "Employee User", "email": "employeeuser@example.com" + }, + { + "id": "8d54", + "firstname": "first", + "lastname": "last", + "age": "12", + "gender": "male", + "email": "firstlast001@gmail.com", + "address_line_1": " Bavdhan, Pune", + "address_line_2": "LOCAL :,Bavdhan", + "nearby_landmark": "sbi bank", + "pincode": "411021", + "city_id": "", + "mobile": "07559393995" } ], "products": [ @@ -122,6 +136,20 @@ "email": "aaaa@gmail.com", "address": "pune", "mobile": "7559393995" + }, + { + "id": "88a4", + "firstname": "first", + "lastname": "last", + "age": "8", + "gender": "male", + "email": "firstlast001@gmail.com", + "address_line_1": "Bavdhan, Pune", + "address_line_2": "LOCAL :,Bavdhan", + "nearby_landmark": "sbi bank", + "pincode": "411021", + "city_id": "", + "mobile": "07559393995" } ] } \ No newline at end of file diff --git a/src/components/admin/AddEmployee.jsx b/src/components/admin/AddEmployee.jsx index 0a0444a..d5be7f3 100644 --- a/src/components/admin/AddEmployee.jsx +++ b/src/components/admin/AddEmployee.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import Sidebar from '../sidebar/Sidebar'; import axiosInstance from '../../api/axiosConfig'; @@ -11,9 +11,31 @@ const AddEmployee = () => { age: '', gender: '', email: '', - address: '', + address_line_1: '', + address_line_2: '', + nearby_landmark: '', + pincode: '', + city_id: '', mobile: '', }); + const [cities, setCities] = useState([]); + + // useEffect(() => { + // const fetchCities = async () => { + // try { + // const response = await axiosInstance.get('/cities'); + // if (Array.isArray(response.data)) { + // setCities(response.data); + // } else { + // console.error('Error: Data is not an array', response.data); + // } + // } catch (error) { + // console.error('Error fetching cities:', error.response || error.message); + // } + // }; + + // fetchCities(); + // }, []); const handleInputChange = (e) => { const { name, value } = e.target; @@ -26,7 +48,7 @@ const AddEmployee = () => { const handleAddEmployeeSubmit = async (e) => { e.preventDefault(); try { - await axiosInstance.post('/employees', employeeData); + await axiosInstance.post('http://localhost:5000/employees', employeeData); navigate('/employees'); } catch (error) { console.error('Error adding employee:', error.response || error.message); @@ -39,7 +61,7 @@ const AddEmployee = () => {
-

creating employee account

+

Creating Employee Account

Skip for now
@@ -48,7 +70,7 @@ const AddEmployee = () => {
@@ -56,7 +78,7 @@ const AddEmployee = () => {
- + { />
- + { />
- + { />
- +
- + { />
- +
- + + +
+
+ + +
+
+ + +
+
+ + +
+
+ {
diff --git a/src/components/customer/AddCustomer.jsx b/src/components/customer/AddCustomer.jsx index 945b1ae..763281b 100644 --- a/src/components/customer/AddCustomer.jsx +++ b/src/components/customer/AddCustomer.jsx @@ -1,21 +1,41 @@ -import React, { useState } from 'react'; -import { Link } from 'react-router-dom'; +import React, { useState, useEffect } from 'react'; +import { Link, useNavigate } from 'react-router-dom'; import Sidebar from '../sidebar/Sidebar'; import axiosInstance from '../../api/axiosConfig'; -import { useNavigate } from 'react-router-dom'; - const AddCustomer = () => { const navigate = useNavigate(); const [customerData, setCustomerData] = useState({ firstname: '', - lastname:'', + lastname: '', age: '', gender: '', email: '', - address: '', + address_line_1: '', + address_line_2: '', + nearby_landmark: '', + pincode: '', + city_id: '', mobile: '', }); + const [cities, setCities] = useState([]); + + // useEffect(() => { + // const fetchCities = async () => { + // try { + // const response = await axiosInstance.get('/cities'); + // if (Array.isArray(response.data)) { + // setCities(response.data); + // } else { + // console.error('Error: Data is not an array', response.data); + // } + // } catch (error) { + // console.error('Error fetching cities:', error.response || error.message); + // } + // }; + + // fetchCities(); + // }, []); const handleInputChange = (e) => { const { name, value } = e.target; @@ -28,121 +48,165 @@ const AddCustomer = () => { const handleAddCustomerSubmit = async (e) => { e.preventDefault(); try { - const response = await axiosInstance.post('http://localhost:5000/customers', customerData); + await axiosInstance.post('http://localhost:5000/customers', customerData); navigate('/customers'); } catch (error) { - console.error(error); + console.error('Error adding customer:', error.response || error.message); } }; return (
-
-
+
+
-

add customer

- skip for now +

Add Customer

+ Skip for now
-
-
-

customer information

+

Customer Information

-

measurements

+

Measurements

- +
- +
- +
- +
- +
- +
- + + +
+
+ + +
+
+ + +
+
+ + +
+
+

-
diff --git a/src/components/customer/CustomerList.jsx b/src/components/customer/CustomerList.jsx index 7d12b5e..30929d1 100644 --- a/src/components/customer/CustomerList.jsx +++ b/src/components/customer/CustomerList.jsx @@ -34,7 +34,7 @@ const CustomerList = () => {

Customers List

- + Home @@ -59,7 +59,7 @@ const AdminSidebar = () => { Catalog - + Employee