code refactor
This commit is contained in:
parent
508ed3de18
commit
37fadb391c
|
@ -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";
|
||||
|
@ -17,12 +17,12 @@ const baseMenuItems = [
|
|||
icon: <HomeRoundedIcon />,
|
||||
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
|
||||
|
|
|
@ -2,21 +2,19 @@ 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[];
|
||||
|
@ -28,7 +26,7 @@ const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ caps, component }) => {
|
|||
if (!localStorage.getItem("authToken")) {
|
||||
return <Navigate to="/auth/login" replace />;
|
||||
}
|
||||
return <>{component}</>;
|
||||
return component;
|
||||
};
|
||||
|
||||
// Combined Router Component
|
||||
|
@ -92,7 +90,7 @@ export default function AppRouter() {
|
|||
</Route>
|
||||
|
||||
{/* Catch-all Route */}
|
||||
<Route path="*" element={<>404</>} />
|
||||
<Route path="*" element={<NotFoundPage/>} />
|
||||
</BaseRoutes>
|
||||
</Suspense>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue