import { createBrowserRouter } from 'react-router';

import { paths } from '@/shared/routing';

import { RootLayout } from './RootLayout';
import { RouteError } from './RouteError';

export const router = createBrowserRouter([
  {
    path: paths.home,
    element: <RootLayout />,
    errorElement: <RouteError />,
    children: [
      {
        index: true,
        lazy: async () => ({
          Component: (await import('@/pages/sample-table')).SampleTablePage,
        }),
      },
      {
        path: paths.notFound,
        lazy: async () => ({
          Component: (await import('@/pages/not-found')).NotFoundPage,
        }),
      },
    ],
  },
]);
