dev-jaanvi #1
18924
package-lock.json
generated
18924
package-lock.json
generated
File diff suppressed because it is too large
Load diff
20
package.json
20
package.json
|
@ -5,31 +5,20 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.0",
|
"@emotion/styled": "^11.14.0",
|
||||||
"@mui/icons-material": "^6.3.0",
|
"@mui/icons-material": "^6.4.5",
|
||||||
"@mui/material": "^6.4.4",
|
"@mui/material": "^6.4.5",
|
||||||
"@mui/x-charts": "^7.23.2",
|
"@mui/x-charts": "^7.27.0",
|
||||||
"@mui/x-data-grid": "^7.23.5",
|
"@mui/x-data-grid": "^7.27.0",
|
||||||
"@mui/x-date-pickers": "^7.27.0",
|
"@mui/x-date-pickers": "^7.27.0",
|
||||||
"@mui/x-tree-view": "^7.23.2",
|
|
||||||
"@react-spring/web": "^9.7.5",
|
"@react-spring/web": "^9.7.5",
|
||||||
"@reduxjs/toolkit": "^2.5.0",
|
"@reduxjs/toolkit": "^2.5.0",
|
||||||
"@types/babel__core": "^7.20.5",
|
"@types/babel__core": "^7.20.5",
|
||||||
"AdapterDayjs": "file:@mui/x-date-pickers/AdapterDayjs",
|
|
||||||
"AppBar": "file:@mui/material/AppBar",
|
|
||||||
"Box": "file:@mui/material/Box",
|
|
||||||
"PieChart": "file:@mui/x-charts/PieChart",
|
|
||||||
"RichTreeView": "file:@mui/x-tree-view/RichTreeView",
|
|
||||||
"Stack": "file:@mui/material/Stack",
|
|
||||||
"Tabs": "file:@mui/material/Tabs",
|
|
||||||
"Toolbar": "file:@mui/material/Toolbar",
|
|
||||||
"Typography": "file:@mui/material/Typography",
|
|
||||||
"add": "^2.0.6",
|
"add": "^2.0.6",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cra-template-typescript": "1.2.0",
|
"cra-template-typescript": "1.2.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"highcharts": "^12.1.2",
|
"highcharts": "^12.1.2",
|
||||||
"hooks": "file:@mui/x-charts/hooks",
|
|
||||||
"mui-phone-number": "^3.0.3",
|
"mui-phone-number": "^3.0.3",
|
||||||
"mui-tel-input": "^7.0.0",
|
"mui-tel-input": "^7.0.0",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
|
@ -42,7 +31,6 @@
|
||||||
"react-router-dom": "^7.1.1",
|
"react-router-dom": "^7.1.1",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"sonner": "^1.7.4",
|
"sonner": "^1.7.4",
|
||||||
"styles": "file:@mui/material/styles",
|
|
||||||
"web-vitals": "^4.2.4"
|
"web-vitals": "^4.2.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
13449
pnpm-lock.yaml
13449
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@ import ListItemIcon from "@mui/material/ListItemIcon";
|
||||||
import ListItemText from "@mui/material/ListItemText";
|
import ListItemText from "@mui/material/ListItemText";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import HomeRoundedIcon from "@mui/icons-material/HomeRounded";
|
import HomeRoundedIcon from "@mui/icons-material/HomeRounded";
|
||||||
// import AnalyticsRoundedIcon from "@mui/icons-material/AnalyticsRounded";
|
import AnalyticsRoundedIcon from "@mui/icons-material/AnalyticsRounded";
|
||||||
import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted";
|
import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
@ -19,12 +19,12 @@ const baseMenuItems = [
|
||||||
icon: <DashboardOutlinedIcon />,
|
icon: <DashboardOutlinedIcon />,
|
||||||
url: "/panel/dashboard",
|
url: "/panel/dashboard",
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// text: "Vehicles",
|
text: "Admins",
|
||||||
// icon: <AnalyticsRoundedIcon />,
|
icon: <AnalyticsRoundedIcon />,
|
||||||
// url: "/panel/vehicles",
|
url: "/panel/admin-list",
|
||||||
// },
|
},
|
||||||
//created by Eknnor and Jaanvi
|
|
||||||
];
|
];
|
||||||
|
|
||||||
//Eknoor singh and Jaanvi
|
//Eknoor singh and Jaanvi
|
||||||
|
|
|
@ -45,7 +45,7 @@ export const loginUser = createAsyncThunk<
|
||||||
//use below commented endpoint if using deployed backend........
|
//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("auth/login", {
|
const response = await http.post("admin/login", {
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,49 +2,31 @@ import {
|
||||||
Routes as BaseRoutes,
|
Routes as BaseRoutes,
|
||||||
Navigate,
|
Navigate,
|
||||||
Route,
|
Route,
|
||||||
RouteProps,
|
|
||||||
} from "react-router-dom";
|
} from "react-router-dom";
|
||||||
import React, { Suspense } from "react";
|
import React, { lazy, Suspense } from "react";
|
||||||
import { useSelector } from "react-redux";
|
|
||||||
import { RootState } from "./redux/store/store";
|
|
||||||
import LoadingComponent from "./components/Loading";
|
import LoadingComponent from "./components/Loading";
|
||||||
import DashboardLayout from "./layouts/DashboardLayout";
|
import DashboardLayout from "./layouts/DashboardLayout";
|
||||||
|
|
||||||
// Page imports
|
// Page imports
|
||||||
import Login from "./pages/Auth/Login";
|
const Login = lazy(() => import("./pages/Auth/Login"));
|
||||||
import SignUp from "./pages/Auth/SignUp";
|
const SignUp = lazy(() => import("./pages/Auth/SignUp"));
|
||||||
import Dashboard from "./pages/Dashboard";
|
const Dashboard = lazy(() => import("./pages/Dashboard"));
|
||||||
import Vehicles from "./pages/Vehicles";
|
const Vehicles = lazy(() => import("./pages/Vehicles"));
|
||||||
import AdminList from "./pages/AdminList";
|
const AdminList = lazy(() => import("./pages/AdminList"));
|
||||||
import ProfilePage from "./pages/ProfilePage";
|
const ProfilePage = lazy(() => import("./pages/ProfilePage"));
|
||||||
|
const NotFoundPage = lazy(() => import("./pages/NotFound"));
|
||||||
|
|
||||||
interface ProtectedRouteProps {
|
interface ProtectedRouteProps {
|
||||||
caps: string[];
|
caps: string[];
|
||||||
component: React.ReactNode;
|
component: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SuperAdminRouteProps {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Protected Route Component
|
// Protected Route Component
|
||||||
const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ caps, component }) => {
|
const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ caps, component }) => {
|
||||||
if (!localStorage.getItem("authToken")) {
|
if (!localStorage.getItem("authToken")) {
|
||||||
return <Navigate to="/auth/login" replace />;
|
return <Navigate to="/auth/login" replace />;
|
||||||
}
|
}
|
||||||
return <>{component}</>;
|
return component;
|
||||||
};
|
|
||||||
|
|
||||||
// Super Admin Route Component
|
|
||||||
const SuperAdminRoute: React.FC<SuperAdminRouteProps> = ({ children }) => {
|
|
||||||
const userRole = useSelector(
|
|
||||||
(state: RootState) => state.profileReducer.user?.role
|
|
||||||
);
|
|
||||||
|
|
||||||
if (userRole !== "superadmin") {
|
|
||||||
return <Navigate to="/panel/dashboard" replace />;
|
|
||||||
}
|
|
||||||
return <>{children}</>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Combined Router Component
|
// Combined Router Component
|
||||||
|
@ -87,15 +69,11 @@ export default function AppRouter() {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="adminlist"
|
path="admin-list"
|
||||||
element={
|
element={
|
||||||
<ProtectedRoute
|
<ProtectedRoute
|
||||||
caps={[]}
|
caps={[]}
|
||||||
component={
|
component={<AdminList />}
|
||||||
<SuperAdminRoute>
|
|
||||||
<AdminList />
|
|
||||||
</SuperAdminRoute>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -109,11 +87,10 @@ export default function AppRouter() {
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path="*" element={<>404</>} />
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{/* Catch-all Route */}
|
{/* Catch-all Route */}
|
||||||
<Route path="*" element={<>404</>} />
|
<Route path="*" element={<NotFoundPage/>} />
|
||||||
</BaseRoutes>
|
</BaseRoutes>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue