Adding endpoint to the json file and modified in Auth login page
This commit is contained in:
parent
d1fa80bac7
commit
f7871882a1
106
db.json
106
db.json
@ -1,67 +1,71 @@
|
|||||||
{
|
{
|
||||||
"users": [
|
"authlogin": [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"email": "employee@example.com",
|
"email": "admin@gmail.com",
|
||||||
"password": "password123",
|
"password": "123",
|
||||||
"role": "employee"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"email": "admin@example.com",
|
|
||||||
"password": "admin123",
|
|
||||||
"role": "admin"
|
"role": "admin"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"email": "employee@example.com",
|
"id": 2,
|
||||||
"password": "password123",
|
"email": "employee@gmail.com",
|
||||||
"id": 3,
|
"password": "123",
|
||||||
"role": "employee"
|
"role": "employee"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"health-check": {
|
||||||
|
"status": "OK"
|
||||||
|
},
|
||||||
|
"admin": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"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": 4,
|
"id": 2,
|
||||||
"email": "suraj@gmail.com",
|
"name": "Product 2",
|
||||||
"password": "pass",
|
"category": "Category 2",
|
||||||
"role": "employee"
|
"price": 200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Category 1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 5
|
"id": 2,
|
||||||
|
"name": "Category 2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"customers": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Customer 1",
|
||||||
|
"email": "customer1@example.com",
|
||||||
|
"phone": "1234567890"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 6
|
"id": 2,
|
||||||
},
|
"name": "Customer 2",
|
||||||
{
|
"email": "customer2@example.com",
|
||||||
"id": 7
|
"phone": "0987654321"
|
||||||
},
|
|
||||||
{
|
|
||||||
"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
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -9,6 +9,8 @@ import AddCustomer from './components/customer/AddCustomer';
|
|||||||
import Sidebar from './components/sidebar/Sidebar';
|
import Sidebar from './components/sidebar/Sidebar';
|
||||||
import CustomerMeasurements from './components/customer/CustomerMeasurements';
|
import CustomerMeasurements from './components/customer/CustomerMeasurements';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { AuthProvider, AuthContext } from './contexts/AuthContext';
|
import { AuthProvider, AuthContext } from './contexts/AuthContext';
|
||||||
|
|
||||||
const { Content } = Layout;
|
const { Content } = Layout;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// src/api/axiosConfig.js
|
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const axiosInstance = axios.create({
|
const axiosInstance = axios.create({
|
||||||
|
@ -14,7 +14,7 @@ const LoginPage = () => {
|
|||||||
setError('');
|
setError('');
|
||||||
|
|
||||||
try {
|
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);
|
const user = response.data.find(user => user.email === email && user.password === password);
|
||||||
|
|
||||||
|
@ -1,8 +1,39 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import axiosInstance from '../../api/axiosConfig';
|
||||||
|
|
||||||
import Sidebar from '../sidebar/Sidebar';
|
import Sidebar from '../sidebar/Sidebar';
|
||||||
|
|
||||||
const AddCustomer = () => {
|
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 (
|
return (
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
@ -34,35 +65,80 @@ const AddCustomer = () => {
|
|||||||
</div>
|
</div>
|
||||||
{/* Form */}
|
{/* Form */}
|
||||||
<div className="md:col-span-2 space-y-4">
|
<div className="md:col-span-2 space-y-4">
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-black-700">Customer Name :</label>
|
<label className="block text-sm font-medium text-black-700">Customer Name :</label>
|
||||||
<input type="text" className="input-underline" />
|
<input
|
||||||
|
type="text"
|
||||||
|
name="name"
|
||||||
|
value={customerData.name}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="input-underline"
|
||||||
|
required
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-black-700">Age :</label>
|
<label className="block text-sm font-medium text-black-700">Age :</label>
|
||||||
<input type="number" className="input-underline" />
|
<input
|
||||||
|
type="number"
|
||||||
|
name="age"
|
||||||
|
value={customerData.age}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="input-underline"
|
||||||
|
required
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-black-700">Gender :</label>
|
<label className="block text-sm font-medium text-black-700">Gender :</label>
|
||||||
<input type="text" className="input-underline" />
|
<input
|
||||||
|
type="text"
|
||||||
|
name="gender"
|
||||||
|
value={customerData.gender}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="input-underline"
|
||||||
|
required
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-black-700">Email :</label>
|
<label className="block text-sm font-medium text-black-700">Email :</label>
|
||||||
<input type="email" className="input-underline" />
|
<input
|
||||||
|
type="email"
|
||||||
|
name="email"
|
||||||
|
value={customerData.email}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="input-underline"
|
||||||
|
required
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-black-700">Address :</label>
|
<label className="block text-sm font-medium text-black-700">Address :</label>
|
||||||
<input type="text" className="input-underline" />
|
<input
|
||||||
|
type="text"
|
||||||
|
name="address"
|
||||||
|
value={customerData.address}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="input-underline"
|
||||||
|
required
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-black-700">Mobile No :</label>
|
<label className="block text-sm font-medium text-black-700">Mobile No :</label>
|
||||||
<input type="text" className="input-underline" />
|
<input
|
||||||
</div>
|
type="text"
|
||||||
|
name="mobileNo"
|
||||||
|
value={customerData.mobileNo}
|
||||||
|
onChange={handleChange}
|
||||||
|
className="input-underline"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div> <br/>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<button className="bg-orange-500 text-black px-4 py-2 rounded-md font-semibold text-sm">
|
<button type="submit" className="bg-orange-500 text-black px-4 py-2 rounded-md font-semibold text-sm">
|
||||||
|
|
||||||
Save Information
|
Save Information
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,6 +4,7 @@ import App from './App';
|
|||||||
import 'antd/dist/reset.css';
|
import 'antd/dist/reset.css';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user