import { createBrowserRouter } from 'react-router-dom'
import AppShell from '@/layouts/AppShell'
import RequireAuth from './RequireAuth'
import LoginPage from '@/pages/login/Login'
import DashboardPage from '@/pages/main/Dashboard'
import UserListPage from '@/pages/usr/UserList'
import UserDetailPage from '@/pages/usr/UserDetail'

export const router = createBrowserRouter([
  { path: '/login', element: <LoginPage /> },
  {
    path: '/',
    element: (
      <RequireAuth>
        <AppShell />
      </RequireAuth>
    ),
    children: [
      { index: true, element: <DashboardPage /> },
      { path: 'users', element: <UserListPage /> },
      { path: 'users/new', element: <UserDetailPage mode="new" /> },
      { path: 'users/:id', element: <UserDetailPage mode="edit" /> },
    ],
  },
])
