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 { 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: 'verify-code',
element: (
),
},
// { path: 'login-unprotected', element: },
// { path: 'register-unprotected', element: },
// { path: 'reset-password', element: },
],
},
{
path: '/',
element: (
),
children: [
{ element: , index: true },
{
path: 'dashboard',
element: ,
},
],
},
{
path: '/alarm-center',
element: (
),
children: [
{
element: ,
index: true,
},
{
path: 'service-monitoring/:id',
element: ,
},
],
},
{
path: '*',
element: ,
children: [
{ path: '404', element: },
{ path: '*', element: },
],
},
{ path: '*', element: },
]);
}
// Auth
const Login = Loadable(lazy(() => import('../pages/auth/Login')));
const VerifyCode = Loadable(lazy(() => import('../pages/auth/VerifyCode')));
// Dashboard
const Dashboard = Loadable(lazy(() => import('../pages/Dashboard/Dashboard')));
const NotFound = Loadable(lazy(() => import('../pages/Page404')));
// Alarm Center
const AlarmCenter = Loadable(lazy(() => import('../pages/AlarmCenter/Index')));
const AlarmCenterServiceMonitoring = Loadable(
lazy(() => import('../pages/AlarmCenter/ServiceMonitoring'))
);