diff --git a/package-lock.json b/package-lock.json index a7f25ba..0b07d4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "clsx": "^2.1.1", "cra-template-typescript": "1.2.0", "dayjs": "^1.11.13", + "highcharts": "^12.1.2", "hooks": "file:@mui/x-charts/hooks", "mui-phone-number": "^3.0.3", "mui-tel-input": "^7.0.0", @@ -9944,6 +9945,12 @@ "he": "bin/he" } }, + "node_modules/highcharts": { + "version": "12.1.2", + "resolved": "https://registry.npmjs.org/highcharts/-/highcharts-12.1.2.tgz", + "integrity": "sha512-paZ72q1um0zZT1sS+O/3JfXVSOLPmZ0zlo8SgRc0rEplPFPQUPc4VpkgQS8IUTueeOBgIWwVpAWyC9tBYbQ0kg==", + "license": "https://www.highcharts.com/license" + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", diff --git a/package.json b/package.json index a11f999..ddba5af 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "clsx": "^2.1.1", "cra-template-typescript": "1.2.0", "dayjs": "^1.11.13", + "highcharts": "^12.1.2", "hooks": "file:@mui/x-charts/hooks", "mui-phone-number": "^3.0.3", "mui-tel-input": "^7.0.0", diff --git a/src/components/AddEditCategoryModal/index.tsx b/src/components/AddEditCategoryModal/index.tsx index 0cb48cb..f092627 100644 --- a/src/components/AddEditCategoryModal/index.tsx +++ b/src/components/AddEditCategoryModal/index.tsx @@ -13,14 +13,22 @@ import { useForm, Controller } from "react-hook-form"; interface AddEditCategoryModalProps { open: boolean; handleClose: () => void; - handleUpdate: (id: string, name: string, role: string) => void; + handleUpdate: ( + id: string, + name: string, + email: string, + phone: string, + registeredAddress: string + ) => void; editRow: any; + handleAdd: Function; } interface FormData { - category: string; - role: string; name: string; + email: string; + phone: string; + registeredAddress: string; } const AddEditCategoryModal: React.FC = ({ @@ -28,6 +36,7 @@ const AddEditCategoryModal: React.FC = ({ handleClose, editRow, handleUpdate, + handleAdd, }) => { const { control, @@ -37,15 +46,30 @@ const AddEditCategoryModal: React.FC = ({ reset, } = useForm({ defaultValues: { - category: "", name: "", - role: "", + email: "", + phone: "", + registeredAddress: "", }, }); const onSubmit = (data: FormData) => { if (editRow) { - handleUpdate(editRow.id, data.name, data.role); + handleUpdate( + editRow.id, + data.name, + data.email, + data.phone, + data.registeredAddress + ); + } else { + // Call handleAdd if adding new admin + handleAdd( + data.name, + data.email, + data.phone, + data.registeredAddress + ); } handleClose(); reset(); @@ -53,9 +77,11 @@ const AddEditCategoryModal: React.FC = ({ useEffect(() => { if (editRow) { - setValue("category", editRow.name); setValue("name", editRow.name); - setValue("role", editRow.role); + setValue("email", editRow.role); + setValue("phone", editRow.phone); + setValue("email", editRow.email); + setValue("registeredAddress", editRow.registeredAddress); } else { reset(); } @@ -73,9 +99,8 @@ const AddEditCategoryModal: React.FC = ({ onSubmit: handleSubmit(onSubmit), }} > - {editRow ? "Edit" : "Add"} Category + {editRow ? "Edit" : "Add"} Admin - = ({ /> ( + )} + /> + ( + + )} + /> + ( + )} /> diff --git a/src/components/CustomTable/index.tsx b/src/components/CustomTable/index.tsx index 737bb66..a4cf326 100644 --- a/src/components/CustomTable/index.tsx +++ b/src/components/CustomTable/index.tsx @@ -1,225 +1,260 @@ -import * as React from "react" -import { styled } from "@mui/material/styles" -import Table from "@mui/material/Table" -import TableBody from "@mui/material/TableBody" -import TableCell, { tableCellClasses } from "@mui/material/TableCell" -import TableContainer from "@mui/material/TableContainer" -import TableHead from "@mui/material/TableHead" -import TableRow from "@mui/material/TableRow" -import Paper, { paperClasses } from "@mui/material/Paper" -import { deleteAdmin } from "../../redux/slices/adminSlice" -import { useDispatch } from "react-redux" +import * as React from "react"; +import { styled } from "@mui/material/styles"; +import Table from "@mui/material/Table"; +import TableBody from "@mui/material/TableBody"; +import TableCell, { tableCellClasses } from "@mui/material/TableCell"; +import TableContainer from "@mui/material/TableContainer"; +import TableHead from "@mui/material/TableHead"; +import TableRow from "@mui/material/TableRow"; +import Paper, { paperClasses } from "@mui/material/Paper"; +import { adminList, deleteAdmin } from "../../redux/slices/adminSlice"; +import { useDispatch } from "react-redux"; import { - Box, - Button, - dividerClasses, - IconButton, - listClasses, - Menu, -} from "@mui/material" -import MoreVertRoundedIcon from "@mui/icons-material/MoreVertRounded" -import DeleteModal from "../Modals/DeleteModal/DeleteModal" -import { AppDispatch } from "../../redux/store/store" + Box, + Button, + dividerClasses, + IconButton, + listClasses, + Menu, +} from "@mui/material"; +import MoreVertRoundedIcon from "@mui/icons-material/MoreVertRounded"; +import DeleteModal from "../Modals/DeleteModal/DeleteModal"; +import { AppDispatch } from "../../redux/store/store"; +import ViewModal from "../Modals/ViewModal/ViewModal"; // Styled components for customization const StyledTableCell = styled(TableCell)(({ theme }) => ({ - [`&.${tableCellClasses.head}`]: { - backgroundColor: " #1565c0", - color: theme.palette.common.white, - }, - [`&.${tableCellClasses.body}`]: { - fontSize: 14, - }, -})) + [`&.${tableCellClasses.head}`]: { + backgroundColor: " #1565c0", + color: theme.palette.common.white, + }, + [`&.${tableCellClasses.body}`]: { + fontSize: 14, + }, +})); const StyledTableRow = styled(TableRow)(({ theme }) => ({ - "&:nth-of-type(odd)": { - backgroundColor: theme.palette.action.hover, - }, - "&:last-child td, &:last-child th": { - border: 0, - }, -})) + "&:nth-of-type(odd)": { + backgroundColor: theme.palette.action.hover, + }, + "&:last-child td, &:last-child th": { + border: 0, + }, +})); export interface Column { - id: string - label: string - align?: "left" | "center" | "right" + id: string; + label: string; + align?: "left" | "center" | "right"; } - + interface Row { - [key: string]: any + [key: string]: any; } - + interface CustomTableProps { - columns: Column[] - rows: Row[] - setDeleteModal: Function - setRowData: Function - setModalOpen: Function - deleteModal: boolean + columns: Column[]; + rows: Row[]; + setDeleteModal: Function; + setRowData: Function; + setModalOpen: Function; + viewModal: boolean; + setViewModal: Function; + deleteModal: boolean; } - + const CustomTable: React.FC = ({ - columns, - rows, - setDeleteModal, - deleteModal, - setRowData, - setModalOpen, + columns, + rows, + setDeleteModal, + deleteModal, + viewModal, + setRowData, + setViewModal, + setModalOpen, }) => { - // console.log("columnsss", columns, rows) - const dispatch = useDispatch() - const [anchorEl, setAnchorEl] = React.useState(null) - const [selectedRow, setSelectedRow] = React.useState(null) - const open = Boolean(anchorEl) + // console.log("columnsss", columns, rows) + const dispatch = useDispatch(); + const [anchorEl, setAnchorEl] = React.useState(null); + const [selectedRow, setSelectedRow] = React.useState(null); + const open = Boolean(anchorEl); - const handleClick = (event: React.MouseEvent, row: Row) => { - setAnchorEl(event.currentTarget) - setSelectedRow(row) // Ensure the row data is set - } + const handleClick = (event: React.MouseEvent, row: Row) => { + setAnchorEl(event.currentTarget); + setSelectedRow(row); // Ensure the row data is set + }; - const handleClose = () => { - setAnchorEl(null) - } + const handleClose = () => { + setAnchorEl(null); + }; - const isImage = (value: any) => { - if (typeof value === "string") { - return value.startsWith("http") || value.startsWith("data:image") // Check for URL or base64 image - } - return false - } + const isImage = (value: any) => { + if (typeof value === "string") { + return value.startsWith("http") || value.startsWith("data:image"); // Check for URL or base64 image + } + return false; + }; - const handleDeleteButton = (id: string | undefined) => { - if (!id) console.error("ID not found", id) + const handleDeleteButton = (id: string | undefined) => { + if (!id) console.error("ID not found", id); - dispatch(deleteAdmin(id || "")) - setDeleteModal(false) // Close the modal only after deletion - handleClose() - } + dispatch(deleteAdmin(id || "")); + setDeleteModal(false); // Close the modal only after deletion + handleClose(); + }; - return ( - - - - - {columns.map((column) => ( - - {column.label} - - ))} - - - - {rows.map((row, rowIndex) => ( - - {columns.map((column) => ( - - {isImage(row[column.id]) ? ( - Row - ) : column.id !== "action" ? ( - row[column.id] - ) : ( - { - handleClick(e, row) - setRowData(row) // Store the selected row - }} - > - - - )} - - ))} - - ))} - -
- {open && ( - - - + const handleViewButton = (id: string | undefined) => { + if (!id) console.error("ID not found", id); + setViewModal(false); + }; - - {deleteModal && ( - - handleDeleteButton(selectedRow?.id) - } - open={deleteModal} - setDeleteModal={setDeleteModal} - id={selectedRow?.id} - /> - )} - - - )} -
- ) -} + return ( + + + + + {columns.map((column) => ( + + {column.label} + + ))} + + + + {rows.map((row, rowIndex) => ( + + {columns.map((column) => ( + + {isImage(row[column.id]) ? ( + Row + ) : column.id !== "action" ? ( + row[column.id] + ) : ( + { + handleClick(e, row); + setRowData(row); // Store the selected row + }} + > + + + )} + + ))} + + ))} + +
+ {open && ( + + + + {viewModal && ( + + handleViewButton(selectedRow?.id) + } + open={viewModal} + setViewModal={setViewModal} + id={selectedRow?.id} + /> + )} + -export default CustomTable + + {deleteModal && ( + + handleDeleteButton(selectedRow?.id) + } + open={deleteModal} + setDeleteModal={setDeleteModal} + id={selectedRow?.id} + /> + )} + + + )} +
+ ); +}; + +export default CustomTable; diff --git a/src/components/LogOut/logOutfunc.tsx b/src/components/LogOut/logOutfunc.tsx new file mode 100644 index 0000000..5f676fa --- /dev/null +++ b/src/components/LogOut/logOutfunc.tsx @@ -0,0 +1,35 @@ +// Logout.tsx +import React from "react"; +import { useNavigate } from "react-router-dom"; +import { toast } from "sonner"; +import LogoutModal from "../Modals/LogoutModal/LogoutModal"; + +interface LogoutProps { + setLogoutModal: React.Dispatch>; + logoutModal: boolean; +} + +const Logout: React.FC = ({ setLogoutModal, logoutModal }) => { + const navigate = useNavigate(); + + const handlelogout = () => { + localStorage.clear(); + navigate("/auth/login"); + toast.success("Logged out successfully"); + setLogoutModal(false); + }; + + return ( + <> + {logoutModal && ( + + )} + + ); +}; + +export default Logout; diff --git a/src/components/MenuContent/index.tsx b/src/components/MenuContent/index.tsx index d4896c2..db17896 100644 --- a/src/components/MenuContent/index.tsx +++ b/src/components/MenuContent/index.tsx @@ -17,11 +17,12 @@ const baseMenuItems = [ icon: , url: "/panel/dashboard", }, - { - text: "Vehicles", - icon: , - url: "/panel/vehicles", - }, + + // { + // text: "Vehicles", + // icon: , + // url: "/panel/vehicles", + // }, //created by Eknnor and Jaanvi ]; diff --git a/src/components/Modals/LogoutModal/LogoutModal.tsx b/src/components/Modals/LogoutModal/LogoutModal.tsx new file mode 100644 index 0000000..1e838ec --- /dev/null +++ b/src/components/Modals/LogoutModal/LogoutModal.tsx @@ -0,0 +1,80 @@ +import { Box, Button, Modal, Typography } from "@mui/material"; + +type Props = { + open: boolean; + setLogoutModal: Function; + handlelogout: any; +}; + +const style = { + position: "absolute", + top: "50%", + left: "50%", + transform: "translate(-50%, -50%)", + width: 330, + bgcolor: "background.paper", + borderRadius: 1.5, + boxShadow: 24, + p: 3, +}; + +const btnStyle = { py: 1, px: 5, width: "50%", textTransform: "capitalize" }; + +export default function LogoutModal({ + open, + setLogoutModal, + handlelogout, +}: Props) { + return ( + + + + Logout + + + Are you sure you want to Logout? + + + + + + + + ); +} diff --git a/src/components/Modals/ViewModal/ViewModal.tsx b/src/components/Modals/ViewModal/ViewModal.tsx new file mode 100644 index 0000000..8a1df15 --- /dev/null +++ b/src/components/Modals/ViewModal/ViewModal.tsx @@ -0,0 +1,82 @@ +import { Box, Button, Modal, Typography } from "@mui/material"; +import { AppDispatch, RootState } from "../../../redux/store/store"; +import { useDispatch, useSelector } from "react-redux"; +import { useEffect, useState } from "react"; + +type Props = { + open: boolean; + setViewModal: Function; + handleView: (id: string | undefined) => void; + id?: string | undefined; +}; +; + +const style = { + position: "absolute", + top: "50%", + left: "50%", + transform: "translate(-50%, -50%)", + width: 330, + bgcolor: "background.paper", + borderRadius: 1.5, + boxShadow: 24, + p: 3, +}; + +const btnStyle = { py: 1, px: 5, width: "50%", textTransform: "capitalize", alignItems: "center" }; + +export default function ViewModal({ + open, + setViewModal, + id, // Selected user's ID +}: Props) { + const { admins } = useSelector((state: RootState) => state.adminReducer); + const [selectedAdmin, setSelectedAdmin] = useState(null); + + useEffect(() => { + if (id) { + const admin = admins.find((admin) => admin.id === id); + setSelectedAdmin(admin || null); + } + }, [id, admins]); + + return ( + + + + Details of {selectedAdmin?.name} + + {selectedAdmin ? ( + <> + Name: {selectedAdmin?.name} + Email: {selectedAdmin?.email} + Phone: {selectedAdmin?.phone} + Address: {selectedAdmin?.registeredAddress} + + ) : ( + No admin found with this ID + )} + + + + + + ); +} \ No newline at end of file diff --git a/src/components/OptionsMenu/index.tsx b/src/components/OptionsMenu/index.tsx index 0e5c474..02684f1 100644 --- a/src/components/OptionsMenu/index.tsx +++ b/src/components/OptionsMenu/index.tsx @@ -12,7 +12,7 @@ import MoreVertRoundedIcon from "@mui/icons-material/MoreVertRounded"; import MenuButton from "../MenuButton"; import { Avatar } from "@mui/material"; import { useNavigate } from "react-router-dom"; -import { toast } from "sonner"; +import Logout from "../LogOut/logOutfunc"; const MenuItem = styled(MuiMenuItem)({ margin: "2px 0", @@ -20,6 +20,7 @@ const MenuItem = styled(MuiMenuItem)({ export default function OptionsMenu({ avatar }: { avatar?: boolean }) { const [anchorEl, setAnchorEl] = React.useState(null); + const [logoutModal, setLogoutModal] = React.useState(false); const open = Boolean(anchorEl); const handleClick = (event: React.MouseEvent) => { setAnchorEl(event?.currentTarget); @@ -32,17 +33,12 @@ export default function OptionsMenu({ avatar }: { avatar?: boolean }) { //Made a navigation page for the profile page const navigate = useNavigate(); const handleProfile = () => { - navigate("/auth/profile"); + navigate("/panel/profile"); }; - //Eknoor singh and jaanvi + //jaanvi //date:- 13-Feb-2025 - //Implemented logout functionality which was static previously - const handlelogout = () => { - localStorage.clear(); - navigate("/auth/login"); - toast.success("Logged out successfully"); - }; + return ( Logout + + { + e.stopPropagation(); + setLogoutModal(true); + }} + > + Logout + + + diff --git a/src/pages/AdminList/index.tsx b/src/pages/AdminList/index.tsx index 4c0d312..11600a3 100644 --- a/src/pages/AdminList/index.tsx +++ b/src/pages/AdminList/index.tsx @@ -6,9 +6,11 @@ import CustomTable, { Column } from "../../components/CustomTable"; import { useDispatch, useSelector } from "react-redux"; import { adminList, updateAdmin } from "../../redux/slices/adminSlice"; import { AppDispatch, RootState } from "../../redux/store/store"; // Import RootState for selector - +import ViewModal from "../../components/Modals/ViewModal/ViewModal"; export default function AdminList() { - const [modalOpen, setModalOpen] = useState(false); + const [modalOpen, setModalOpen,] = useState(false); + const [viewModal, setViewOpen] = useState(false); + const { reset } = useForm(); const [deleteModal, setDeleteModal] = React.useState(false); @@ -26,16 +28,29 @@ export default function AdminList() { const handleClickOpen = () => { setModalOpen(true); + setViewOpen(true); }; const handleCloseModal = () => { setModalOpen(false); + setViewOpen(false) reset(); }; - const handleUpdate = async (id: string, name: string, role: string) => { + const handleUpdate = async ( + id: string, + name: string, + email: string, + phone:string, + registeredAddress:string + ) => { try { - await dispatch(updateAdmin({ id, name, role })); + await dispatch( + updateAdmin({ + id, name, email, phone, registeredAddress, + token: null + }) + ); await dispatch(adminList()); // Fetch updated admins list after update } catch (error) { console.error("Update failed", error); @@ -45,7 +60,10 @@ export default function AdminList() { const categoryColumns: Column[] = [ { id: "srno", label: "Sr No" }, { id: "name", label: "Name" }, - { id: "role", label: "Role" }, + { id: "email", label: "Email" }, + { id: "phone", label: "Phone No" }, + { id: "registeredAddress", label: "Address" }, + { id: "action", label: "Action", align: "center" }, ]; @@ -53,13 +71,21 @@ export default function AdminList() { const categoryRows = admins?.length ? admins?.map( ( - admin: { id: string; name: string; role: string }, + admin: { + id: string; + name: string; + email: string; + phone: string; + registeredAddress: string; + }, index: number ) => ({ id: admin?.id, srno: index + 1, name: admin?.name, - role: admin?.role, + email: admin?.email, + phone: admin?.phone, + registeredAddress: admin?.registeredAddress, }) ) : []; @@ -91,24 +117,28 @@ export default function AdminList() { sx={{ textAlign: "right" }} onClick={handleClickOpen} > - Add Category + Add Admin - + + + ); } diff --git a/src/pages/Auth/Login/index.tsx b/src/pages/Auth/Login/index.tsx index 050b087..01b86da 100644 --- a/src/pages/Auth/Login/index.tsx +++ b/src/pages/Auth/Login/index.tsx @@ -1,214 +1,227 @@ -import * as React from 'react'; -import Box from '@mui/material/Box'; -import Button from '@mui/material/Button'; -import Checkbox from '@mui/material/Checkbox'; -import CssBaseline from '@mui/material/CssBaseline'; -import FormControlLabel from '@mui/material/FormControlLabel'; -import Divider from '@mui/material/Divider'; -import FormLabel from '@mui/material/FormLabel'; -import FormControl from '@mui/material/FormControl'; -import Link from '@mui/material/Link'; -import TextField from '@mui/material/TextField'; -import Typography from '@mui/material/Typography'; -import Stack from '@mui/material/Stack'; -import MuiCard from '@mui/material/Card'; -import { styled } from '@mui/material/styles'; -import { useForm, Controller, SubmitHandler } from 'react-hook-form'; -import { useDispatch } from 'react-redux'; -import { loginUser } from '../../../redux/slices/authSlice.ts'; -import ColorModeSelect from '../../../shared-theme/ColorModeSelect.tsx'; -import AppTheme from '../../../shared-theme/AppTheme.tsx'; -import ForgotPassword from './ForgotPassword.tsx'; -import { toast } from 'sonner'; -import { useNavigate } from 'react-router-dom'; +import * as React from "react"; +import Box from "@mui/material/Box"; +import Button from "@mui/material/Button"; +import Checkbox from "@mui/material/Checkbox"; +import CssBaseline from "@mui/material/CssBaseline"; +import FormControlLabel from "@mui/material/FormControlLabel"; +import Divider from "@mui/material/Divider"; +import FormLabel from "@mui/material/FormLabel"; +import FormControl from "@mui/material/FormControl"; +import Link from "@mui/material/Link"; +import TextField from "@mui/material/TextField"; +import Typography from "@mui/material/Typography"; +import Stack from "@mui/material/Stack"; +import MuiCard from "@mui/material/Card"; +import { styled } from "@mui/material/styles"; +import { useForm, Controller, SubmitHandler } from "react-hook-form"; +import { useDispatch } from "react-redux"; +import { loginUser } from "../../../redux/slices/authSlice.ts"; +import ColorModeSelect from "../../../shared-theme/ColorModeSelect.tsx"; +import AppTheme from "../../../shared-theme/AppTheme.tsx"; +import ForgotPassword from "./ForgotPassword.tsx"; +import { toast } from "sonner"; +import { useNavigate } from "react-router-dom"; const Card = styled(MuiCard)(({ theme }) => ({ - display: 'flex', - flexDirection: 'column', - alignSelf: 'center', - width: '100%', - padding: theme.spacing(4), - gap: theme.spacing(2), - margin: 'auto', - [theme.breakpoints.up('sm')]: { - maxWidth: '450px', - }, - boxShadow: - 'hsla(220, 30%, 5%, 0.05) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.05) 0px 15px 35px -5px', - ...theme.applyStyles('dark', { - boxShadow: - 'hsla(220, 30%, 5%, 0.5) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.08) 0px 15px 35px -5px', - }), + display: "flex", + flexDirection: "column", + alignSelf: "center", + width: "100%", + padding: theme.spacing(4), + gap: theme.spacing(2), + margin: "auto", + [theme.breakpoints.up("sm")]: { + maxWidth: "450px", + }, + boxShadow: + "hsla(220, 30%, 5%, 0.05) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.05) 0px 15px 35px -5px", + ...theme.applyStyles("dark", { + boxShadow: + "hsla(220, 30%, 5%, 0.5) 0px 5px 15px 0px, hsla(220, 25%, 10%, 0.08) 0px 15px 35px -5px", + }), })); const SignInContainer = styled(Stack)(({ theme }) => ({ - height: 'calc((1 - var(--template-frame-height, 0)) * 100dvh)', - minHeight: '100%', - padding: theme.spacing(2), - [theme.breakpoints.up('sm')]: { - padding: theme.spacing(4), - }, - '&::before': { - content: '""', - display: 'block', - position: 'absolute', - zIndex: -1, - inset: 0, - backgroundImage: - 'radial-gradient(ellipse at 50% 50%, hsl(210, 100%, 97%), hsl(0, 0%, 100%))', - backgroundRepeat: 'no-repeat', - ...theme.applyStyles('dark', { - backgroundImage: - 'radial-gradient(at 50% 50%, hsla(210, 100%, 16%, 0.5), hsl(220, 30%, 5%))', - }), - }, + height: "calc((1 - var(--template-frame-height, 0)) * 100dvh)", + minHeight: "100%", + padding: theme.spacing(2), + [theme.breakpoints.up("sm")]: { + padding: theme.spacing(4), + }, + "&::before": { + content: '""', + display: "block", + position: "absolute", + zIndex: -1, + inset: 0, + backgroundImage: + "radial-gradient(ellipse at 50% 50%, hsl(210, 100%, 97%), hsl(0, 0%, 100%))", + backgroundRepeat: "no-repeat", + ...theme.applyStyles("dark", { + backgroundImage: + "radial-gradient(at 50% 50%, hsla(210, 100%, 16%, 0.5), hsl(220, 30%, 5%))", + }), + }, })); interface ILoginForm { - email: string; - password: string; + email: string; + password: string; } export default function Login(props: { disableCustomTheme?: boolean }) { - const [open, setOpen] = React.useState(false); - const { - control, - handleSubmit, - formState: { errors }, - setError, - } = useForm(); - const dispatch = useDispatch(); - const router = useNavigate(); - const handleClickOpen = () => { - setOpen(true); - }; + const [open, setOpen] = React.useState(false); + const { + control, + handleSubmit, + formState: { errors }, + setError, + } = useForm(); + const dispatch = useDispatch(); + const router = useNavigate(); + const handleClickOpen = () => { + setOpen(true); + }; - const handleClose = () => { - setOpen(false); - }; + const handleClose = () => { + setOpen(false); + }; - const onSubmit: SubmitHandler = async (data: ILoginForm) => { - try { - const response = await dispatch(loginUser(data)).unwrap(); - if (response?.data?.token) { - router('/panel/dashboard'); - } - } catch (error: any) { - console.log('Login failed:', error); - toast.error('Login failed: ' + error); - } - }; + const onSubmit: SubmitHandler = async (data: ILoginForm) => { + try { + const response = await dispatch(loginUser(data)).unwrap(); + if (response?.data?.token) { + router("/panel/dashboard"); + } + } catch (error: any) { + console.log("Login failed:", error); + toast.error("Login failed: " + error); + } + }; - return ( - - - - - - {/* */} - Digi-EV - - Sign in - - - - Email - ( - - )} - /> - + return ( + + + + + + {/* */} + Digi-EV + + Sign in + + + + Email + ( + + )} + /> + - - Password - ( - - )} - /> - + + Password + ( + + )} + /> + - } - label="Remember me" - /> - - - - Forgot your password? - - - or + + } + label="Remember me" + /> + + + {/* + Forgot your password? + */} + + {/* or Don't have an account?{' '} @@ -220,9 +233,9 @@ export default function Login(props: { disableCustomTheme?: boolean }) { Sign up - - - - - ); + */} + + + + ); } diff --git a/src/pages/Vehicles/index.tsx b/src/pages/Vehicles/index.tsx index db9710a..9429afa 100644 --- a/src/pages/Vehicles/index.tsx +++ b/src/pages/Vehicles/index.tsx @@ -6,17 +6,17 @@ import CustomTable from '../../components/CustomTable'; import DeleteModal from '../../components/Modals/DeleteModal/DeleteModal'; // Sample data for categories -const categoryRows = [ - { srno: 1, name: 'Strength', date: '01/03/2025' }, - { - srno: 2, - name: 'HIIT (High-Intensity Interval Training)', - date: '01/03/2025', - }, - { srno: 3, name: 'Cardio', date: '01/03/2025' }, - { srno: 4, name: 'Combat', date: '01/03/2025' }, - { srno: 5, name: 'Yoga', date: '01/03/2025' }, -]; +// const categoryRows = [ +// { srno: 1, name: 'Strength', date: '01/03/2025' }, +// { +// srno: 2, +// name: 'HIIT (High-Intensity Interval Training)', +// date: '01/03/2025', +// }, +// { srno: 3, name: 'Cardio', date: '01/03/2025' }, +// { srno: 4, name: 'Combat', date: '01/03/2025' }, +// { srno: 5, name: 'Yoga', date: '01/03/2025' }, +// ]; export default function Vehicles() { const [modalOpen, setModalOpen] = useState(false); @@ -66,9 +66,9 @@ export default function Vehicles() { }} > {/* Title and Add Category button */} - + {/* Vehicles - + */}