Merge branch 'develop' of https://git.digimantra.com/DigiMantra/digiev_frontend into feature/loginPage
This commit is contained in:
commit
f488dd1646
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": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.0",
|
||||
"@mui/icons-material": "^6.3.0",
|
||||
"@mui/material": "^6.4.4",
|
||||
"@mui/x-charts": "^7.23.2",
|
||||
"@mui/x-data-grid": "^7.23.5",
|
||||
"@mui/icons-material": "^6.4.5",
|
||||
"@mui/material": "^6.4.5",
|
||||
"@mui/x-charts": "^7.27.0",
|
||||
"@mui/x-data-grid": "^7.27.0",
|
||||
"@mui/x-date-pickers": "^7.27.0",
|
||||
"@mui/x-tree-view": "^7.23.2",
|
||||
"@react-spring/web": "^9.7.5",
|
||||
"@reduxjs/toolkit": "^2.5.0",
|
||||
"@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",
|
||||
"axios": "^1.7.9",
|
||||
"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",
|
||||
"prop-types": "^15.8.1",
|
||||
|
@ -42,7 +31,6 @@
|
|||
"react-router-dom": "^7.1.1",
|
||||
"react-scripts": "5.0.1",
|
||||
"sonner": "^1.7.4",
|
||||
"styles": "file:@mui/material/styles",
|
||||
"web-vitals": "^4.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
13611
pnpm-lock.yaml
13611
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 Stack from "@mui/material/Stack";
|
||||
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 { Link, useLocation } from "react-router-dom";
|
||||
import { useSelector } from "react-redux";
|
||||
|
@ -19,12 +19,12 @@ const baseMenuItems = [
|
|||
icon: <DashboardOutlinedIcon />,
|
||||
url: "/panel/dashboard",
|
||||
},
|
||||
// {
|
||||
// text: "Vehicles",
|
||||
// icon: <AnalyticsRoundedIcon />,
|
||||
// url: "/panel/vehicles",
|
||||
// },
|
||||
//created by Eknnor and Jaanvi
|
||||
{
|
||||
text: "Admins",
|
||||
icon: <AnalyticsRoundedIcon />,
|
||||
url: "/panel/admin-list",
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
//Eknoor singh and Jaanvi
|
||||
|
|
|
@ -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("auth/login", {
|
||||
const response = await http.post("admin/login", {
|
||||
email,
|
||||
password,
|
||||
});
|
||||
|
|
|
@ -2,49 +2,31 @@ import {
|
|||
Routes as BaseRoutes,
|
||||
Navigate,
|
||||
Route,
|
||||
RouteProps,
|
||||
} from "react-router-dom";
|
||||
import React, { Suspense } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootState } from "./redux/store/store";
|
||||
import React, { lazy, Suspense } from "react";
|
||||
import LoadingComponent from "./components/Loading";
|
||||
import DashboardLayout from "./layouts/DashboardLayout";
|
||||
|
||||
// Page imports
|
||||
import Login from "./pages/Auth/Login";
|
||||
import SignUp from "./pages/Auth/SignUp";
|
||||
import Dashboard from "./pages/Dashboard";
|
||||
import Vehicles from "./pages/Vehicles";
|
||||
import AdminList from "./pages/AdminList";
|
||||
import ProfilePage from "./pages/ProfilePage";
|
||||
const Login = lazy(() => import("./pages/Auth/Login"));
|
||||
const SignUp = lazy(() => import("./pages/Auth/SignUp"));
|
||||
const Dashboard = lazy(() => import("./pages/Dashboard"));
|
||||
const Vehicles = lazy(() => import("./pages/Vehicles"));
|
||||
const AdminList = lazy(() => import("./pages/AdminList"));
|
||||
const ProfilePage = lazy(() => import("./pages/ProfilePage"));
|
||||
const NotFoundPage = lazy(() => import("./pages/NotFound"));
|
||||
|
||||
interface ProtectedRouteProps {
|
||||
caps: string[];
|
||||
component: React.ReactNode;
|
||||
}
|
||||
|
||||
interface SuperAdminRouteProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
// Protected Route Component
|
||||
const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ caps, component }) => {
|
||||
if (!localStorage.getItem("authToken")) {
|
||||
return <Navigate to="/auth/login" replace />;
|
||||
}
|
||||
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}</>;
|
||||
return component;
|
||||
};
|
||||
|
||||
// Combined Router Component
|
||||
|
@ -87,15 +69,11 @@ export default function AppRouter() {
|
|||
}
|
||||
/>
|
||||
<Route
|
||||
path="adminlist"
|
||||
path="admin-list"
|
||||
element={
|
||||
<ProtectedRoute
|
||||
caps={[]}
|
||||
component={
|
||||
<SuperAdminRoute>
|
||||
<AdminList />
|
||||
</SuperAdminRoute>
|
||||
}
|
||||
component={<AdminList />}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
@ -109,11 +87,10 @@ export default function AppRouter() {
|
|||
/>
|
||||
}
|
||||
/>
|
||||
<Route path="*" element={<>404</>} />
|
||||
</Route>
|
||||
|
||||
{/* Catch-all Route */}
|
||||
<Route path="*" element={<>404</>} />
|
||||
<Route path="*" element={<NotFoundPage/>} />
|
||||
</BaseRoutes>
|
||||
</Suspense>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue