1import { lazy } from 'react';
2import { createHashRouter } from 'react-router-dom';
3import { fetchAdminLoader } from 'service/http';
4import { pages } from 'stores';
5
6const ConsoleLayout = lazy(() => import('layouts/console-layout'));
7const Home = lazy(() => import('./home'));
8const Hosts = lazy(() => import('./hosts'));
9const Users = lazy(() => import('./users'));
10const Login = lazy(() => import('./login'));
11const Nodes = lazy(() => import('./nodes'));
12const Services = lazy(() => import('./services'));
13
14export const router = createHashRouter([
15 {
16 path: '/',
17 errorElement: <Login />,
18 loader: fetchAdminLoader,
19 element: <ConsoleLayout />,
20 children: [
21 {
22 path: pages.home.path,
23 element: <Home />,
24 },
25 {
26 path: pages.users.path,
27 element: <Users />,
28 },
29 {
30 path: pages.services.path,
31 element: <Services />,
32 },
33 {
34 path: pages.nodes.path,
35 element: <Nodes />,
36 },
37 {
38 path: pages.hosts.path,
39 element: <Hosts />,
40 },
41 ],
42 },
43 {
44 path: '/login/',
45 element: <Login />,
46 },
47]);