From 7a8a31c482e888abe24b682ab157509fed5fe23d Mon Sep 17 00:00:00 2001 From: surajb Date: Fri, 26 Jul 2024 14:35:56 +0530 Subject: [PATCH] desgin implementation --- db.json | 24 ++++++- lib/api/axiosConfig.js | 3 +- src/components/Auth/LoginPage.css | 83 ++++------------------- src/components/Auth/LoginPage.jsx | 76 +++++++++++---------- src/components/customer/AddCustomer.jsx | 88 +++++++++---------------- src/pages/EmployeeDashboard.jsx | 2 +- src/services/server.js | 18 ++++- tailwind.config.cjs | 2 + 8 files changed, 123 insertions(+), 173 deletions(-) diff --git a/db.json b/db.json index 66ebc10..0fdecc7 100644 --- a/db.json +++ b/db.json @@ -165,5 +165,27 @@ "city_id": "", "mobile": "07559393995" } + ], + "cities": [ + { + "id": "1", + "name": "New York" + }, + { + "id": "2", + "name": "Los Angeles" + }, + { + "id": "3", + "name": "Chicago" + }, + { + "id": "4", + "name": "Houston" + }, + { + "id": "5", + "name": "Phoenix" + } ] -} \ No newline at end of file +} diff --git a/lib/api/axiosConfig.js b/lib/api/axiosConfig.js index b2f0722..de424bc 100644 --- a/lib/api/axiosConfig.js +++ b/lib/api/axiosConfig.js @@ -1,7 +1,8 @@ import axios from 'axios'; const axiosInstance = axios.create({ - baseURL: 'http://localhost:5000' + baseURL: 'http://localhost:5000', + timeout: 10000, }); export default axiosInstance; \ No newline at end of file diff --git a/src/components/Auth/LoginPage.css b/src/components/Auth/LoginPage.css index bafd8fe..124b45d 100644 --- a/src/components/Auth/LoginPage.css +++ b/src/components/Auth/LoginPage.css @@ -5,10 +5,8 @@ body, html { padding: 0; font-family: 'Nunito Sans', sans-serif; background-color: #ffffff; - /* color: #fff; */ } - .login-page { display: flex; align-items: center; @@ -16,34 +14,15 @@ body, html { min-height: 100vh; padding: 4rem; background-color: #ffffff; -} - -.login-container { - /* background-color: #222; */ - border-radius: 8px; - padding: 40px; - box-shadow: 0 0 10px #d1d5db; - width: 310.4px; - display: flex; - flex-direction: column; - row-gap: 28px; - column-gap: 28px; - font-size: 14px; - font-weight: 500; - line-height: 14px; - box-sizing: border-box; -} - -.form-container { - display: flex; - flex-direction: column; - align-items: center; + position: relative; } .logo { - display: block; - margin: 0 auto 20px; - width: 100px; + position: absolute; + top: 1rem; + left: 1rem; + width: 100px; + height: auto; } h1 { @@ -58,44 +37,20 @@ p { text-align: center; } -form { - display: flex; - flex-direction: column; - align-items: center; - width: 100%; -} - -label { - display: none; -} - -/* input[type="email"], -input[type="password"] { +input { width: 100%; padding: 12px; margin-bottom: 20px; border: 1px solid #B3B3B3; border-radius: 4px; font-size: 16px; - background-color: #09090B; - color: #fff; + background-color: #e8e8e8; + color: #4b5563; box-sizing: border-box; -} */ - -.login-page input { - width: 100%; - padding: 12px; - margin-bottom: 20px; - border: 1px solid #B3B3B3; /* Darker border */ - border-radius: 4px; - font-size: 16px; - background-color: #e8e8e8; /* Dark background for input fields */ - color: #4b5563; /* White text for input fields */ } -input[type="email"]:focus, -input[type="password"]:focus { - border-color: #4b5563; +input:focus { + border-color: #0e355b; outline: none; } @@ -112,10 +67,6 @@ input[type="password"]:focus { text-decoration: none; } -/* .forgot-password-container a:hover { - text-decoration: underline; -} */ - .login-button { width: 100%; padding: 15px 30px; @@ -130,15 +81,3 @@ input[type="password"]:focus { .login-button:hover { background-color: #154676; } - -.login-page input:focus { - border-color: #0e355b; /* Orange border on focus */ - outline: none; -} - -.login-page a { - color: #4b5563; - text-decoration: none; - margin-bottom: 20px; - display: inline-block; -} diff --git a/src/components/Auth/LoginPage.jsx b/src/components/Auth/LoginPage.jsx index 846e697..a2250d7 100644 --- a/src/components/Auth/LoginPage.jsx +++ b/src/components/Auth/LoginPage.jsx @@ -1,7 +1,6 @@ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import axiosInstance from '../../api/axiosConfig'; -import './LoginPage.css'; import BrookslogoIcon from '../../assets/thob-data/BrookslogoIcon.svg'; const LoginPage = () => { @@ -19,7 +18,7 @@ const LoginPage = () => { const user = response.data.find(user => user.email === email && user.password === password); if (user) { - localStorage.setItem("loggedInUser", JSON.stringify(user)) + localStorage.setItem("loggedInUser", JSON.stringify(user)); if (user.role === 'admin') { navigate('/admin'); } else if (user.role === 'employee') { @@ -42,43 +41,42 @@ const LoginPage = () => { }; return ( -
-
-
- Logo -

welcome back

-

be among the first to experience 3D magic! register for private alpha.

- {error &&

{error}

} -
- - setEmail(e.target.value)} - placeholder="john123@domain.com" - required - className="input-field" - /> - - setPassword(e.target.value)} - placeholder="Enter your password" - required - className="input-field" - /> - - -
+
+ Logo +
+

welcome back

+

be among the first to experience 3D magic! Register for private alpha.

+ {error &&

{error}

} +
+ setEmail(e.target.value)} + placeholder="john123@domain.com" + required + className="w-full p-3 border border-gray-300 rounded-md text-gray-700 focus:border-primary focus:outline-none" + /> + setPassword(e.target.value)} + placeholder="Enter your password" + required + className="w-full p-3 border border-gray-300 rounded-md text-gray-700 focus:border-primary focus:outline-none" + /> + +
diff --git a/src/components/customer/AddCustomer.jsx b/src/components/customer/AddCustomer.jsx index 815c14a..ed333ff 100644 --- a/src/components/customer/AddCustomer.jsx +++ b/src/components/customer/AddCustomer.jsx @@ -21,13 +21,12 @@ const CLASSES = { imagePreview: 'bg-gray-300 w-24 h-24 rounded-full mx-auto overflow-hidden', noImage: 'w-full h-full flex items-center justify-center text-gray-500', hiddenInput: 'hidden', - uploadButton: - 'absolute bottom-0 left-1/2 transform -translate-x-1/2 bg-gray-700 text-white text-xs px-2 py-1 rounded-full', + uploadButton: 'absolute bottom-0 left-1/2 transform -translate-x-1/2 bg-gray-700 text-white text-xs px-2 py-1 rounded-full', linkTitle: 'text-lg font-semibold', formSection: 'md:col-span-2 space-y-4', - formGroup: 'block text-gray-800 font-medium', - formInput: 'w-full p-2 border-b border-gray-400 focus:border-gray-700', - formSelect: 'w-full p-2 border-b border-gray-400 focus:border-gray-700', + formGroup: ' text-gray-800 font-medium', + formInput: ' p-2 border-b border-gray-400 focus:border-gray-700', + formSelect: ' p-2 border-b border-gray-400 focus:border-gray-700', submitButton: 'bg-[#0e355b] text-white py-2 px-4 rounded-md', }; @@ -40,7 +39,6 @@ const AddCustomer = () => { gender: '', email: '', mobile: '', - image: null, address: { address_line_1: '', address_line_2: '', @@ -48,9 +46,10 @@ const AddCustomer = () => { pincode: '', city_id: '', }, + image: null, }); - const [cities, setCities] = useState([]); + const [cities, setCities] = useState([]); const [imagePreview, setImagePreview] = useState(null); useEffect(() => { @@ -63,7 +62,7 @@ const AddCustomer = () => { console.error('Error: Data is not an array', response.data); } } catch (error) { - console.error('Error fetching cities:', error.response || error.message); + console.error('Error fetching cities:', error.response ? error.response.data : error.message); } }; @@ -78,17 +77,6 @@ const AddCustomer = () => { })); }; - const handleAddressChange = (e) => { - const { name, value } = e.target; - setCustomerData((prevData) => ({ - ...prevData, - address: { - ...prevData.address, - [name]: value, - }, - })); - }; - const handleImageChange = (e) => { const file = e.target.files[0]; if (file) { @@ -104,18 +92,12 @@ const AddCustomer = () => { e.preventDefault(); const formData = new FormData(); Object.keys(customerData).forEach((key) => { - if (key === 'address') { - Object.keys(customerData.address).forEach((addrKey) => { - formData.append(`address[${addrKey}]`, customerData.address[addrKey]); - }); - } else { - formData.append(key, customerData[key]); - } + formData.append(key, customerData[key]); }); try { const response = await axiosInstance.post( - 'http://localhost:5000/customers', + '/customers', formData, { headers: { @@ -123,7 +105,6 @@ const AddCustomer = () => { }, } ); - console.log('Raw response:', response); console.log('Customer added successfully:', response.data); navigate('/customers'); } catch (error) { @@ -176,7 +157,7 @@ const AddCustomer = () => { } className={CLASSES.uploadButton} > - Upload + upload
@@ -229,9 +210,7 @@ const AddCustomer = () => { onChange={handleInputChange} className={CLASSES.formSelect} > - + @@ -252,8 +231,8 @@ const AddCustomer = () => {
@@ -262,8 +241,8 @@ const AddCustomer = () => { @@ -272,8 +251,8 @@ const AddCustomer = () => { @@ -282,8 +261,8 @@ const AddCustomer = () => { @@ -291,36 +270,31 @@ const AddCustomer = () => {
-
- -
+ diff --git a/src/pages/EmployeeDashboard.jsx b/src/pages/EmployeeDashboard.jsx index 3e2bb77..3816e6f 100644 --- a/src/pages/EmployeeDashboard.jsx +++ b/src/pages/EmployeeDashboard.jsx @@ -36,7 +36,7 @@ const EmployeeDashboard = () => {
-

Home

+

employee dashboard

welcome back, {userName}

diff --git a/src/services/server.js b/src/services/server.js index d3cfbec..6dbec0b 100644 --- a/src/services/server.js +++ b/src/services/server.js @@ -1,4 +1,3 @@ -// server.js const express = require('express'); const bodyParser = require('body-parser'); const nodemailer = require('nodemailer'); @@ -10,11 +9,26 @@ const port = 5000; app.use(bodyParser.json()); let users = [ - // Example users { email: 'admin@example.com', password: 'admin123', role: 'admin' }, { email: 'employee@example.com', password: 'employee123', role: 'employee' }, ]; +// Endpoint to handle login requests +app.post('/auth/login', (req, res) => { + const { email, password } = req.body; + const user = users.find(user => user.email === email && user.password === password); + + if (!user) { + return res.status(401).json({ success: false, message: 'Invalid email or password' }); + } + + res.status(200).json({ + success: true, + message: 'Login successful', + role: user.role, + }); +}); + // Endpoint to handle password reset requests app.post('/auth/forgot-password', (req, res) => { const { email } = req.body; diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 4489c31..ca101d4 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -1,4 +1,5 @@ /** @type {import('tailwindcss').Config} */ + module.exports = { content: [ './src/**/*.{html,js,jsx}', @@ -13,6 +14,7 @@ module.exports = { 'secondary-text': '#4b5563', 'button-text': '#d1d5db', }, + fontFamily: { sans: ['"Nunito Sans"', 'sans-serif'], },