diff --git a/db.json b/db.json index f126f68..5ac12c1 100644 --- a/db.json +++ b/db.json @@ -1,67 +1,71 @@ { - "users": [ + "authlogin": [ + { + "id": 1, + "email": "admin@gmail.com", + "password": "123", + "role": "admin" + }, + { + "id": 2, + "email": "employee@gmail.com", + "password": "123", + "role": "employee" + } + ], + "health-check": { + "status": "OK" + }, + "admin": [ { "id": 1, - "email": "employee@example.com", - "password": "password123", - "role": "employee" + "name": "Admin User", + "email": "adminuser@example.com" + } + ], + "employee": [ + { + "id": 1, + "name": "Employee User", + "email": "employeeuser@example.com" + } + ], + "products": [ + { + "id": 1, + "name": "Product 1", + "category": "Category 1", + "price": 100 }, { "id": 2, - "email": "admin@example.com", - "password": "admin123", - "role": "admin" + "name": "Product 2", + "category": "Category 2", + "price": 200 + } + ], + "categories": [ + { + "id": 1, + "name": "Category 1" }, { - "email": "employee@example.com", - "password": "password123", - "id": 3, - "role": "employee" + "id": 2, + "name": "Category 2" + } + ], + "customers": [ + { + "id": 1, + "name": "Customer 1", + "email": "customer1@example.com", + "phone": "1234567890" }, { - "id": 4, - "email": "suraj@gmail.com", - "password": "pass", - "role": "employee" - }, - { - "id": 5 - }, - { - "id": 6 - }, - { - "id": 7 - }, - { - "id": 8 - }, - { - "id": 9 - }, - { - "id": 10 - }, - { - "id": 11, - "email": "urhtuhreiuuryuihd@gmail.com", - "password": "password12", - "role": "employee" - }, - { - "id": 12 - }, - { - "id": 13 - }, - { - "id": 14 - }, - { - "id": 15 - }, - { - "id": 16 + "id": 2, + "name": "Customer 2", + "email": "customer2@example.com", + "phone": "0987654321" } ] -} \ No newline at end of file +} diff --git a/src/App.jsx b/src/App.jsx index b8bc81e..d736882 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -9,6 +9,8 @@ import AddCustomer from './components/customer/AddCustomer'; import Sidebar from './components/sidebar/Sidebar'; import CustomerMeasurements from './components/customer/CustomerMeasurements'; + + import { AuthProvider, AuthContext } from './contexts/AuthContext'; const { Content } = Layout; diff --git a/src/api/axiosConfig.jsx b/src/api/axiosConfig.jsx index 30c0e54..a736a40 100644 --- a/src/api/axiosConfig.jsx +++ b/src/api/axiosConfig.jsx @@ -1,5 +1,3 @@ -// src/api/axiosConfig.js - import axios from 'axios'; const axiosInstance = axios.create({ diff --git a/src/components/Auth/LoginPage.jsx b/src/components/Auth/LoginPage.jsx index 39cc383..771252c 100644 --- a/src/components/Auth/LoginPage.jsx +++ b/src/components/Auth/LoginPage.jsx @@ -14,7 +14,7 @@ const LoginPage = () => { setError(''); try { - const response = await axiosInstance.get('http://localhost:5000/users'); + const response = await axiosInstance.get('http://localhost:5000/authlogin'); const user = response.data.find(user => user.email === email && user.password === password); diff --git a/src/components/customer/AddCustomer.jsx b/src/components/customer/AddCustomer.jsx index 87229d0..eae4436 100644 --- a/src/components/customer/AddCustomer.jsx +++ b/src/components/customer/AddCustomer.jsx @@ -1,13 +1,44 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Link } from 'react-router-dom'; +import axiosInstance from '../../api/axiosConfig'; + import Sidebar from '../sidebar/Sidebar'; const AddCustomer = () => { + const [customerData, setCustomerData] = useState({ + name: '', + age: '', + gender: '', + email: '', + address: '', + mobileNo: '' + }); + + const handleChange = (e) => { + const { name, value } = e.target; + setCustomerData({ + ...customerData, + [name]: value + }); + }; + + const handleSubmit = async (e) => { + e.preventDefault(); + try { + const response = await axiosInstance.post('/api/customers', customerData); + console.log('Customer data saved:', response.data); + + } catch (error) { + console.error('Error saving customer data:', error); + + } + }; + return (
-
-
+
+

Add Customer

skip for now @@ -34,35 +65,80 @@ const AddCustomer = () => {
{/* Form */}
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +

+
+ +
+
diff --git a/src/main.jsx b/src/main.jsx index 8c24c5a..1c0141e 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -4,6 +4,7 @@ import App from './App'; import 'antd/dist/reset.css'; import './index.css'; + ReactDOM.createRoot(document.getElementById('root')).render(