diff --git a/db.json b/db.json index 5ac12c1..f7ee222 100644 --- a/db.json +++ b/db.json @@ -1,18 +1,18 @@ { "authlogin": [ - { - "id": 1, - "email": "admin@gmail.com", - "password": "123", - "role": "admin" - }, - { - "id": 2, - "email": "employee@gmail.com", - "password": "123", - "role": "employee" - } - ], + { + "id": 1, + "email": "admin@gmail.com", + "password": "123", + "role": "admin" + }, + { + "id": 2, + "email": "employee@gmail.com", + "password": "123", + "role": "employee" + } + ], "health-check": { "status": "OK" }, @@ -66,6 +66,33 @@ "name": "Customer 2", "email": "customer2@example.com", "phone": "0987654321" + }, + { + "name": "Suraj Birewar", + "age": "24", + "gender": "Male", + "email": "surajbirewar001@gmail.com", + "address": "Bavdhan, Pune", + "mobile": "07559393995", + "id": 3 + }, + { + "name": "rahul", + "age": "21", + "gender": "male", + "email": "rahul001@gmail.com", + "address": "Bavdhan, Pune", + "mobile": "7559393995", + "id": 4 + }, + { + "name": "atharv", + "age": "19", + "gender": "male", + "email": "atharv@gmail.com", + "address": "baner pune ", + "mobile": "784365873", + "id": 5 } ] -} +} \ No newline at end of file diff --git a/src/App.css b/src/App.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/categories/CategoryList.jsx b/src/components/categories/CategoryList.jsx new file mode 100644 index 0000000..8cbef7e --- /dev/null +++ b/src/components/categories/CategoryList.jsx @@ -0,0 +1,37 @@ +import React, { useState, useEffect } from 'react'; +import { Link } from 'react-router-dom'; +import axiosInstance from '../../api/axiosConfig'; +import Sidebar from '../sidebar/Sidebar'; + +const CategoryList = () => { + const [categories, setCategories] = useState([]); + + useEffect(() => { + axios.get('http://localhost:3001/categories') + .then(response => { + setCategories(response.data); + }) + .catch(error => { + console.error('Error fetching categories:', error); + }); + }, []); + + return ( +
+

Categories

+
+ {categories.map(category => ( + +
+ {category.name} +

{category.name}

+

click to view products

+
+ + ))} +
+
+ ); +}; + +export default CategoryList; diff --git a/src/components/categories/ProductList.jsx b/src/components/categories/ProductList.jsx new file mode 100644 index 0000000..6f232b7 --- /dev/null +++ b/src/components/categories/ProductList.jsx @@ -0,0 +1,34 @@ +import React, { useState, useEffect } from 'react'; +import { useParams } from 'react-router-dom'; +import axios from 'axios'; + +const ProductList = () => { + const { category } = useParams(); + const [products, setProducts] = useState([]); + + useEffect(() => { + axios.get(`http://localhost:3001/products?category=${category}`) + .then(response => { + setProducts(response.data); + }) + .catch(error => { + console.error('Error fetching products:', error); + }); + }, [category]); + + return ( +
+

Products in {category}

+
+ {products.map(product => ( +
+

{product.name}

+

Price: ${product.price}

+
+ ))} +
+
+ ); +}; + +export default ProductList; diff --git a/src/components/customer/AddCustomer.jsx b/src/components/customer/AddCustomer.jsx index eae4436..dc30b43 100644 --- a/src/components/customer/AddCustomer.jsx +++ b/src/components/customer/AddCustomer.jsx @@ -1,36 +1,36 @@ import React, { useState } from 'react'; import { Link } from 'react-router-dom'; -import axiosInstance from '../../api/axiosConfig'; - 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({ name: '', age: '', gender: '', email: '', address: '', - mobileNo: '' + mobile: '', }); - const handleChange = (e) => { + const handleInputChange = (e) => { const { name, value } = e.target; setCustomerData({ ...customerData, - [name]: value + [name]: value, }); }; - const handleSubmit = async (e) => { + const handleAddCustomerSubmit = async (e) => { e.preventDefault(); try { - const response = await axiosInstance.post('/api/customers', customerData); - console.log('Customer data saved:', response.data); - + const response = await axiosInstance.post('http://localhost:5000/customers', customerData); + navigate('/customers'); } catch (error) { - console.error('Error saving customer data:', error); - + console.error(error); } }; @@ -41,10 +41,9 @@ const AddCustomer = () => {

Add Customer

- skip for now + Skip for now
- {/* Sidebar */}
@@ -63,78 +62,75 @@ const AddCustomer = () => {
- {/* Form */}
-
+
- +
- +
- - Gender: +
- +
- +
- + -

+
+
diff --git a/src/components/customer/CustomerList.jsx b/src/components/customer/CustomerList.jsx index d32623c..3cf3ec1 100644 --- a/src/components/customer/CustomerList.jsx +++ b/src/components/customer/CustomerList.jsx @@ -1,19 +1,27 @@ import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import Sidebar from '../sidebar/Sidebar'; - +import axiosInstance from '../../api/axiosConfig'; const CustomerList = () => { const [customers, setCustomers] = useState([]); const navigate = useNavigate(); useEffect(() => { // Fetch the customers data from the JSON file - fetch('/customers.json') - .then((response) => response.json()) - .then((data) => setCustomers(data)) - .catch((error) => console.error('Error fetching customers:', error)); + getCustomers() }, []); + const getCustomers = async () => { + try { + const response = await axiosInstance.get('http://localhost:5000/customers'); + let customers_data = response.data; // List of customers + setCustomers(customers_data) + } catch (error) { + throw error; + } + }; + + const handleAddCustomer = () => { navigate('/add-customer'); }; diff --git a/src/components/customer/CustomerMeasurements.jsx b/src/components/customer/CustomerMeasurements.jsx index 616397e..6613383 100644 --- a/src/components/customer/CustomerMeasurements.jsx +++ b/src/components/customer/CustomerMeasurements.jsx @@ -28,7 +28,7 @@ const CustomerMeasurements = () => {

Customer Measurements

- skip for now + skip for now

Upper Body Measurements

diff --git a/src/components/sidebar/AdminSidebar.jsx b/src/components/sidebar/AdminSidebar.jsx index a56ae80..275b914 100644 --- a/src/components/sidebar/AdminSidebar.jsx +++ b/src/components/sidebar/AdminSidebar.jsx @@ -1,12 +1,8 @@ import React from 'react'; -import { Layout, Button } from 'antd'; -import { Link } from 'react-router-dom'; -import './Sidebar.css'; +import { useNavigate } from 'react-router-dom'; -const { Sider } = Layout; - - -import HomeIcon from '../../assets/thob-data/HomeIcon.svg'; +// Import your SVG icons +import HomeIcon from '../../assets/thob-data/HomeIcon.svg'; import AddCustomerIcon from '../../assets/thob-data/AddCustomerIcon.svg'; import OrdersIcon from '../../assets/thob-data/OrdersIcon.svg'; import CategoriesIcon from '../../assets/thob-data/CategoriesIcon.svg'; @@ -16,41 +12,49 @@ import MeasurmentsIcon from '../../assets/thob-data/MeasurmentsIcon.svg'; import ProfileIcon from '../../assets/thob-data/ProfileIcon.svg'; import LogoutIcon from '../../assets/thob-data/LogoutIcon.svg'; -const AdminSidebar = () => { +const Sidebar = () => { + const navigate = useNavigate(); + + const handleNavigation = (link) => { + navigate(link); + }; + return ( - -
t.
-
- -