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"; import RoleList from "./pages/RoleList"; import AddEditRolePage from "./pages/AddEditRolePage"; // Page imports 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")); const UserList = lazy(() => import("./pages/UserList")); interface ProtectedRouteProps { caps: string[]; component: React.ReactNode; } // Protected Route Component const ProtectedRoute: React.FC = ({ caps, component }) => { if (!localStorage.getItem("authToken")) { return ; } return component; }; // Combined Router Component export default function AppRouter() { return ( }> {/* Default Route */} } index /> {/* Auth Routes */} } index /> } /> } /> {/* Dashboard Routes */} }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* Catch-all Route */} } /> ); }