diff --git a/src/components/LogOut/logOutfunc.tsx b/src/components/LogOut/logOutfunc.tsx index 5f676fa..feb9caf 100644 --- a/src/components/LogOut/logOutfunc.tsx +++ b/src/components/LogOut/logOutfunc.tsx @@ -14,7 +14,7 @@ const Logout: React.FC = ({ setLogoutModal, logoutModal }) => { const handlelogout = () => { localStorage.clear(); - navigate("/auth/login"); + navigate("/login"); toast.success("Logged out successfully"); setLogoutModal(false); }; diff --git a/src/components/LogOutFunction/LogOutFunction.tsx b/src/components/LogOutFunction/LogOutFunction.tsx index 6ee8e2d..4e31d84 100644 --- a/src/components/LogOutFunction/LogOutFunction.tsx +++ b/src/components/LogOutFunction/LogOutFunction.tsx @@ -14,7 +14,7 @@ const Logout: React.FC = ({ setLogoutModal, logoutModal }) => { const handlelogout = () => { localStorage.clear(); - navigate("/auth/login"); + navigate("/login"); toast.success("Logged out successfully"); setLogoutModal(false); }; diff --git a/src/components/MainGrid/index.tsx b/src/components/MainGrid/index.tsx index bb8f0d2..4125198 100644 --- a/src/components/MainGrid/index.tsx +++ b/src/components/MainGrid/index.tsx @@ -1,79 +1,66 @@ -import * as React from 'react'; -import Grid from '@mui/material/Grid2'; -import Box from '@mui/material/Box'; -import Stack from '@mui/material/Stack'; -import Typography from '@mui/material/Typography'; -import Copyright from '../../pages/Dashboard/internals/components/Copyright'; -import ChartUserByCountry from '../ChartUserByCountry'; -import CustomizedTreeView from '../CustomizedTreeView'; -import CustomizedDataGrid from '../CustomizedDataGrid'; -import HighlightedCard from '../HighlightedCard'; -import PageViewsBarChart from '../PageViewsBarChart'; -import SessionsChart from '../SessionsChart'; -import StatCard, { StatCardProps } from '../StatCard'; +import * as React from "react"; +import Grid from "@mui/material/Grid2"; +import Box from "@mui/material/Box"; +import Stack from "@mui/material/Stack"; +import Typography from "@mui/material/Typography"; +import Copyright from "../../pages/Dashboard/internals/components/Copyright"; +import ChartUserByCountry from "../ChartUserByCountry"; +import CustomizedTreeView from "../CustomizedTreeView"; +import CustomizedDataGrid from "../CustomizedDataGrid"; +import HighlightedCard from "../HighlightedCard"; +import PageViewsBarChart from "../PageViewsBarChart"; +import SessionsChart from "../SessionsChart"; +import StatCard, { StatCardProps } from "../StatCard"; const data: StatCardProps[] = [ - { - title: 'Users', - value: '14k', - interval: 'Last 30 days', - trend: 'up', - data: [ - 200, 24, 220, 260, 240, 380, 100, 240, 280, 240, 300, 340, 320, 360, 340, - 380, 360, 400, 380, 420, 400, 640, 340, 460, 440, 480, 460, 600, 880, 920, - ], - }, - { - title: 'Conversions', - value: '325', - interval: 'Last 30 days', - trend: 'down', - data: [ - 1640, 1250, 970, 1130, 1050, 900, 720, 1080, 900, 450, 920, 820, 840, 600, - 820, 780, 800, 760, 380, 740, 660, 620, 840, 500, 520, 480, 400, 360, 300, - 220, - ], - }, - { - title: 'Event count', - value: '200k', - interval: 'Last 30 days', - trend: 'neutral', - data: [ - 500, 400, 510, 530, 520, 600, 530, 520, 510, 730, 520, 510, 530, 620, 510, - 530, 520, 410, 530, 520, 610, 530, 520, 610, 530, 420, 510, 430, 520, 510, - ], - }, + { + title: "Total Charge Stations", + value: "86", + }, + { + title: "Charging Completed", + value: "12", + }, + { + title: "Active Users", + value: "24", + }, + { + title: "Total Energy Consumed", + value: "08", + }, ]; export default function MainGrid() { - return ( - - {/* cards */} - - Overview - - theme.spacing(2) }} - > - {data.map((card, index) => ( - - - - ))} - - - - - - - - - - - - ); + return ( + + {/* cards */} + + Overview + + theme.spacing(2) }} + > + {data.map((card, index) => ( + + + + ))} + + + + + + + + + + + + + + ); } diff --git a/src/components/MenuContent/index.tsx b/src/components/MenuContent/index.tsx index 1a086c5..4cf2366 100644 --- a/src/components/MenuContent/index.tsx +++ b/src/components/MenuContent/index.tsx @@ -19,11 +19,11 @@ const baseMenuItems = [ icon: , url: "/panel/dashboard", }, - { - text: "Admins", - icon: , - url: "/panel/admin-list", - }, + // { + // text: "Admins", + // icon: , + // url: "/panel/admin-list", + // }, ]; @@ -35,7 +35,7 @@ const superAdminOnlyItems = [ { text: "Admin List", icon: , - url: "/panel/adminlist", + url: "/panel/admin-list", }, ]; @@ -53,7 +53,18 @@ export default function MenuContent({ hidden }: PropType) { ...baseMenuItems, ...(userRole === "superadmin" ? superAdminOnlyItems : []), ]; - + // const mainListItems = [ + // ...baseMenuItems, + // // ...(userRole === "superadmin" + // // ? [ + // // // { + // // // text: "Admin List", + // // // icon: , + // // // url: "/panel/admin-list", + // // // }, + // // ] + // // : []), + // ]; return ( diff --git a/src/components/SessionsChart/index.tsx b/src/components/SessionsChart/index.tsx index 546f9aa..e87c2f7 100644 --- a/src/components/SessionsChart/index.tsx +++ b/src/components/SessionsChart/index.tsx @@ -1,150 +1,144 @@ -import * as React from 'react'; -import { useTheme } from '@mui/material/styles'; -import Card from '@mui/material/Card'; -import CardContent from '@mui/material/CardContent'; -import Chip from '@mui/material/Chip'; -import Typography from '@mui/material/Typography'; -import Stack from '@mui/material/Stack'; -import { LineChart } from '@mui/x-charts/LineChart'; - -function AreaGradient({ color, id }: { color: string; id: string }) { - return ( - - - - - - - ); -} - -function getDaysInMonth(month: number, year: number) { - const date = new Date(year, month, 0); - const monthName = date.toLocaleDateString('en-US', { - month: 'short', - }); - const daysInMonth = date.getDate(); - const days = []; - let i = 1; - while (days.length < daysInMonth) { - days.push(`${monthName} ${i}`); - i += 1; - } - return days; -} +import * as React from "react"; +import { useTheme } from "@mui/material/styles"; +import Card from "@mui/material/Card"; +import CardContent from "@mui/material/CardContent"; +import Chip from "@mui/material/Chip"; +import Typography from "@mui/material/Typography"; +import Stack from "@mui/material/Stack"; +import { LineChart } from "@mui/x-charts/LineChart"; +import Box from "@mui/material/Box"; +import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown"; export default function SessionsChart() { - const theme = useTheme(); - const data = getDaysInMonth(4, 2024); + return ( + + + + Charging prices + + + + Delhi NCR EV Station + + + - const colorPalette = [ - theme.palette.primary.light, - theme.palette.primary.main, - theme.palette.primary.dark, - ]; - - return ( - - - - Sessions - - - - - 13,277 - - - - - Sessions per day for the last 30 days - - - (i + 1) % 5 === 0, - }, - ]} - series={[ - { - id: 'direct', - label: 'Direct', - showMark: false, - curve: 'linear', - stack: 'total', - area: true, - stackOrder: 'ascending', - data: [ - 300, 900, 600, 1200, 1500, 1800, 2400, 2100, 2700, 3000, 1800, 3300, - 3600, 3900, 4200, 4500, 3900, 4800, 5100, 5400, 4800, 5700, 6000, - 6300, 6600, 6900, 7200, 7500, 7800, 8100, - ], - }, - { - id: 'referral', - label: 'Referral', - showMark: false, - curve: 'linear', - stack: 'total', - area: true, - stackOrder: 'ascending', - data: [ - 500, 900, 700, 1400, 1100, 1700, 2300, 2000, 2600, 2900, 2300, 3200, - 3500, 3800, 4100, 4400, 2900, 4700, 5000, 5300, 5600, 5900, 6200, - 6500, 5600, 6800, 7100, 7400, 7700, 8000, - ], - }, - { - id: 'organic', - label: 'Organic', - showMark: false, - curve: 'linear', - stack: 'total', - stackOrder: 'ascending', - data: [ - 1000, 1500, 1200, 1700, 1300, 2000, 2400, 2200, 2600, 2800, 2500, - 3000, 3400, 3700, 3200, 3900, 4100, 3500, 4300, 4500, 4000, 4700, - 5000, 5200, 4800, 5400, 5600, 5900, 6100, 6300, - ], - area: true, - }, - ]} - height={250} - margin={{ left: 50, right: 20, top: 20, bottom: 20 }} - grid={{ horizontal: true }} - sx={{ - '& .MuiAreaElement-series-organic': { - fill: "url('#organic')", - }, - '& .MuiAreaElement-series-referral': { - fill: "url('#referral')", - }, - '& .MuiAreaElement-series-direct': { - fill: "url('#direct')", - }, - }} - slotProps={{ - legend: { - hidden: true, - }, - }} - > - - - - - - - ); + {/* Grid container for the four boxes */} + + + {/* Box 1 Content */} + + Basic Charging + + + 16.83 cents/kWh + + + + {/* Box 2 Content */} + + Basic Charging + + + 16.83 cents/kWh + + + + + Basic Charging + + + 16.83 cents/kWh + + + + + Basic Charging + + + 16.83 cents/kWh + + + + + + ); } diff --git a/src/components/StatCard/index.tsx b/src/components/StatCard/index.tsx index d587001..3cd344d 100644 --- a/src/components/StatCard/index.tsx +++ b/src/components/StatCard/index.tsx @@ -12,118 +12,26 @@ import { areaElementClasses } from '@mui/x-charts/LineChart'; export type StatCardProps = { title: string; value: string; - interval: string; - trend: 'up' | 'down' | 'neutral'; - data: number[]; + }; -function getDaysInMonth(month: number, year: number) { - const date = new Date(year, month, 0); - const monthName = date.toLocaleDateString('en-US', { - month: 'short', - }); - const daysInMonth = date.getDate(); - const days = []; - let i = 1; - while (days.length < daysInMonth) { - days.push(`${monthName} ${i}`); - i += 1; - } - return days; -} - -function AreaGradient({ color, id }: { color: string; id: string }) { - return ( - - - - - - - ); -} export default function StatCard({ title, value, - interval, - trend, - data, }: StatCardProps) { - const theme = useTheme(); - const daysInWeek = getDaysInMonth(4, 2024); - const trendColors = { - up: - theme.palette.mode === 'light' - ? theme.palette.success.main - : theme.palette.success.dark, - down: - theme.palette.mode === 'light' - ? theme.palette.error.main - : theme.palette.error.dark, - neutral: - theme.palette.mode === 'light' - ? theme.palette.grey[400] - : theme.palette.grey[700], - }; - - const labelColors = { - up: 'success' as const, - down: 'error' as const, - neutral: 'default' as const, - }; - - const color = labelColors[trend]; - const chartColor = trendColors[trend]; - const trendValues = { up: '+25%', down: '-25%', neutral: '+5%' }; return ( - - - - {title} - - - - - - {value} - - - - - {interval} - - - - - - - - - - + + + + {title} + + + {value} + + + ); } diff --git a/src/pages/Auth/Login/index.tsx b/src/pages/Auth/Login/index.tsx index f4f878a..89aa9f8 100644 --- a/src/pages/Auth/Login/index.tsx +++ b/src/pages/Auth/Login/index.tsx @@ -328,7 +328,7 @@ export default function Login(props: { disableCustomTheme?: boolean }) { Don't have an account?{" "} diff --git a/src/pages/Auth/SignUp/index.tsx b/src/pages/Auth/SignUp/index.tsx index 54fff8b..8deaf91 100644 --- a/src/pages/Auth/SignUp/index.tsx +++ b/src/pages/Auth/SignUp/index.tsx @@ -133,7 +133,7 @@ export default function SignUp(props: { disableCustomTheme?: boolean }) { }; await dispatch(registerUser(payload)).unwrap(); - navigate("/auth/login"); + navigate("/login"); toast.success("Registration successful!"); } catch (error: any) { toast.error(error?.message || "Registration failed"); @@ -347,7 +347,7 @@ export default function SignUp(props: { disableCustomTheme?: boolean }) { Already have an account?   diff --git a/src/pages/Dashboard/index.tsx b/src/pages/Dashboard/index.tsx index abb04e2..aedabdf 100644 --- a/src/pages/Dashboard/index.tsx +++ b/src/pages/Dashboard/index.tsx @@ -30,7 +30,7 @@ const Dashboard: React.FC = ({ disableCustomTheme = false }) => {!disableCustomTheme ? ( - <> + <> ) : ( = ({ disableCustomTheme = false }) => Dashboard - - No content available on the Dashboard yet. - + )} diff --git a/src/redux/slices/adminSlice.ts b/src/redux/slices/adminSlice.ts index 29fa7da..5d48ade 100644 --- a/src/redux/slices/adminSlice.ts +++ b/src/redux/slices/adminSlice.ts @@ -37,7 +37,7 @@ export const adminList = createAsyncThunk< { rejectValue: string } >("FetchAdminList", async (_, { rejectWithValue }) => { try { - const response = await http.get("auth/admin-list"); + const response = await http.get("/admin-list"); return response?.data?.data; } catch (error: any) { toast.error("Error fetching users list" + error); @@ -55,7 +55,7 @@ export const deleteAdmin = createAsyncThunk< { rejectValue: string } >("deleteAdmin", async (id, { rejectWithValue }) => { try { - const response = await http.delete(`auth/${id}/delete-admin`); + const response = await http.delete(`/${id}/delete-admin`); toast.success(response.data?.message); return id; } catch (error: any) { @@ -76,9 +76,9 @@ export const createAdmin = createAsyncThunk< registeredAddress: string; }, { rejectValue: string } ->("auth/signup", async (data, { rejectWithValue }) => { +>("/create-admin", async (data, { rejectWithValue }) => { try { - const response = await http.post("auth/create-admin", data); + const response = await http.post("/create-admin", data); return response.data; } catch (error: any) { return rejectWithValue( @@ -92,10 +92,7 @@ export const updateAdmin = createAsyncThunk( "updateAdmin", async ({ id, ...userData }: User, { rejectWithValue }) => { try { - const response = await http.put( - `auth/${id}/update-admin`, - userData - ); + const response = await http.put(`/${id}/update-admin`, userData); toast.success("Admin updated successfully"); return response?.data; } catch (error: any) { diff --git a/src/redux/slices/authSlice.ts b/src/redux/slices/authSlice.ts index ec63b8a..549ecdf 100644 --- a/src/redux/slices/authSlice.ts +++ b/src/redux/slices/authSlice.ts @@ -45,7 +45,7 @@ export const loginUser = createAsyncThunk< //use below commented endpoint if using deployed backend........ // const response = await http.post("admin/login", { - const response = await http.post("admin/login", { + const response = await http.post("/login", { email, password, }); @@ -75,7 +75,7 @@ export const registerUser = createAsyncThunk< { rejectValue: string } >("SignUpUser", async (data, { rejectWithValue }) => { try { - const response = await http.post("auth/signup", data); + const response = await http.post("/signup", data); return response.data; } catch (error: any) { return rejectWithValue( diff --git a/src/redux/slices/profileSlice.ts b/src/redux/slices/profileSlice.ts index 1054f08..f881512 100644 --- a/src/redux/slices/profileSlice.ts +++ b/src/redux/slices/profileSlice.ts @@ -26,7 +26,7 @@ export const fetchAdminProfile = createAsyncThunk< const token = localStorage?.getItem("authToken"); if (!token) throw new Error("No token found"); - const response = await http.get("/auth/profile"); + const response = await http.get("/profile"); if (!response.data?.data) throw new Error("Invalid API response"); diff --git a/src/router.tsx b/src/router.tsx index 06b35b6..4b94c16 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -1,8 +1,4 @@ -import { - Routes as BaseRoutes, - Navigate, - Route, -} from "react-router-dom"; +import { Routes as BaseRoutes, Navigate, Route } from "react-router-dom"; import React, { lazy, Suspense } from "react"; import LoadingComponent from "./components/Loading"; import DashboardLayout from "./layouts/DashboardLayout"; @@ -24,7 +20,7 @@ interface ProtectedRouteProps { // Protected Route Component const ProtectedRoute: React.FC = ({ caps, component }) => { if (!localStorage.getItem("authToken")) { - return ; + return ; } return component; }; @@ -35,13 +31,13 @@ export default function AppRouter() { }> {/* Default Route */} - } index /> + } index /> {/* Auth Routes */} - + } + element={} index /> } /> @@ -90,7 +86,7 @@ export default function AppRouter() { {/* Catch-all Route */} - } /> + } /> );