import {createRoot} from 'react-dom/client'
import {createHashRouter, Navigate, type RouteObject, RouterProvider} from 'react-router'
import './index.scss'
import './components/amis/Registry.ts'
import Overview from './pages/Overview.tsx'
import Root from './pages/Root.tsx'
import Test from './pages/Test.tsx'
import StockList from './pages/stock/StockList.tsx'
import TaskList from './pages/task/TaskList.tsx'
import TaskTemplateList from './pages/task/TaskTemplateList.tsx'
import TaskScheduleList from './pages/task/TaskScheduleList.tsx'
import TaskScheduleSave from './pages/task/TaskScheduleSave.tsx'
import StockCollectionList from './pages/stock/StockCollectionList.tsx'
import TaskDetail from './pages/task/TaskDetail.tsx'
import StockCollectionDetail from './pages/stock/StockCollectionDetail.tsx'

const routes: RouteObject[] = [
  {
    path: '/',
    Component: Root,
    children: [
      {
        index: true,
        element: <Navigate to="/overview" replace/>,
      },
      {
        path: 'overview',
        Component: Overview,
      },
      {
        path: 'stock',
        children: [
          {
            path: 'list',
            Component: StockList,
          },
          {
            path: "collection",
            children: [
              {
                path: 'list',
                Component: StockCollectionList,
              },
              {
                path: 'detail/:id',
                Component: StockCollectionDetail,
              },
            ],
          },
        ],
      },
      {
        path: 'task',
        children: [
          {
            path: 'list',
            Component: TaskList,
          },
          {
            path: 'detail/:id',
            Component: TaskDetail,
          },
          {
            path: 'template',
            children: [
              {
                path: 'list',
                Component: TaskTemplateList,
              },
            ],
          },
          {
            path: 'schedule',
            children: [
              {
                path: 'list',
                Component: TaskScheduleList,
              },
              {
                path: 'save',
                Component: TaskScheduleSave,
              },
            ],
          },
        ],
      },
      {
        path: 'test',
        Component: Test,
      },
    ],
  },
]

createRoot(document.getElementById('root')!).render(
  <RouterProvider router={createHashRouter(routes)}/>,
)
