import { Suspense, lazy, ElementType } from 'react'; import { Navigate, useRoutes, useLocation } from 'react-router-dom'; // layouts import DashboardLayout from '../layouts/dashboard'; import LogoOnlyLayout from '../layouts/LogoOnlyLayout'; // components import LoadingScreen from '../components/LoadingScreen'; import GuestGuard from '../guards/GuestGuard'; import { RegisterForm } from '../sections/auth/register'; import Register from '../pages/auth/Register'; import ResetPassword from '../pages/auth/ResetPassword'; import VerifyCode from '../pages/auth/VerifyCode'; import { AuthProvider } from '../contexts/LaravelAuthContext'; import AuthGuard from '../guards/AuthGuard'; // ---------------------------------------------------------------------- const Loadable = (Component: ElementType) => (props: any) => { // eslint-disable-next-line react-hooks/rules-of-hooks const { pathname } = useLocation(); return ( }> ); }; export default function Router() { return useRoutes([ { path: 'auth', children: [ { path: 'login', element: ( ), }, { path: 'register', element: ( ), }, // { path: 'login-unprotected', element: }, // { path: 'register-unprotected', element: }, // { path: 'reset-password', element: }, // { path: 'verify', element: }, ], }, // { // path: '/', // element: , // }, { path: '/', element: ( ), children:[ { element: , index: true }, { path: 'dashboard', element: , }, { path: 'members', element: , }, ] }, // { // path: '/dashboard', // element: , // children: [ // { element: , index: true }, // { path: 'one', element: // }, // { path: 'two', element: // }, // { path: 'three', element: // }, // { // path: 'user', // children: [ // { element: , index: true }, // { path: 'four', element: }, // { path: 'six', element: }, // ], // }, // ], // }, { path: '*', element: , children: [ { path: '404', element: }, { path: '*', element: }, ], }, { path: '*', element: }, ]); } const Login = Loadable(lazy(() => import('../pages/auth/Login'))); // Dashboard const Dashboard = Loadable(lazy(() => import('../pages/Dashboard'))); const NotFound = Loadable(lazy(() => import('../pages/Page404'))); // Members const Members = Loadable(lazy(() => import('../pages/Members/Index'))); const MedicinesCreate = Loadable(lazy(() => import('../pages/Medicines/Create')));