// vibe_erp web SPA route table.
//
// One <Routes> for the whole SPA: /login is open, everything else
// nests under <ProtectedRoute><AppLayout/>. The layout component
// renders <Outlet/> for the active child route.
//
// **Why a flat route table.** v1 has 12 screens; nested routing
// would just be ceremony. Future chunks can introduce nested
// routes when, e.g., the Settings area gets sub-tabs.

import { Navigate, Route, Routes } from 'react-router-dom'
import { AppLayout } from '@/layout/AppLayout'
import { ProtectedRoute } from '@/components/ProtectedRoute'
import { LoginPage } from '@/pages/LoginPage'
import { DashboardPage } from '@/pages/DashboardPage'
import { UsersPage } from '@/pages/UsersPage'
import { CreateUserPage } from '@/pages/CreateUserPage'
import { UserDetailPage } from '@/pages/UserDetailPage'
import { RolesPage } from '@/pages/RolesPage'
import { ItemsPage } from '@/pages/ItemsPage'
import { CreateItemPage } from '@/pages/CreateItemPage'
import { EditItemPage } from '@/pages/EditItemPage'
import { UomsPage } from '@/pages/UomsPage'
import { PartnersPage } from '@/pages/PartnersPage'
import { CreatePartnerPage } from '@/pages/CreatePartnerPage'
import { EditPartnerPage } from '@/pages/EditPartnerPage'
import { LocationsPage } from '@/pages/LocationsPage'
import { CreateLocationPage } from '@/pages/CreateLocationPage'
import { BalancesPage } from '@/pages/BalancesPage'
import { AdjustStockPage } from '@/pages/AdjustStockPage'
import { MovementsPage } from '@/pages/MovementsPage'
import { SalesOrdersPage } from '@/pages/SalesOrdersPage'
import { CreateSalesOrderPage } from '@/pages/CreateSalesOrderPage'
import { SalesOrderDetailPage } from '@/pages/SalesOrderDetailPage'
import { PurchaseOrdersPage } from '@/pages/PurchaseOrdersPage'
import { CreatePurchaseOrderPage } from '@/pages/CreatePurchaseOrderPage'
import { PurchaseOrderDetailPage } from '@/pages/PurchaseOrderDetailPage'
import { WorkOrdersPage } from '@/pages/WorkOrdersPage'
import { CreateWorkOrderPage } from '@/pages/CreateWorkOrderPage'
import { WorkOrderDetailPage } from '@/pages/WorkOrderDetailPage'
import { ShopFloorPage } from '@/pages/ShopFloorPage'
import { AccountsPage } from '@/pages/AccountsPage'
import { JournalEntriesPage } from '@/pages/JournalEntriesPage'
import { FormDesignerPage } from '@/pages/FormDesignerPage'
import { ListViewDesignerPage } from '@/pages/ListViewDesignerPage'
import { MetadataAdminPage } from '@/pages/MetadataAdminPage'

export default function App() {
  return (
    <Routes>
      <Route path="/login" element={<LoginPage />} />
      <Route
        path="/"
        element={
          <ProtectedRoute>
            <AppLayout />
          </ProtectedRoute>
        }
      >
        <Route index element={<DashboardPage />} />
        <Route path="users" element={<UsersPage />} />
        <Route path="users/new" element={<CreateUserPage />} />
        <Route path="users/:id" element={<UserDetailPage />} />
        <Route path="roles" element={<RolesPage />} />
        <Route path="items" element={<ItemsPage />} />
        <Route path="items/new" element={<CreateItemPage />} />
        <Route path="items/:id/edit" element={<EditItemPage />} />
        <Route path="uoms" element={<UomsPage />} />
        <Route path="partners" element={<PartnersPage />} />
        <Route path="partners/new" element={<CreatePartnerPage />} />
        <Route path="partners/:id/edit" element={<EditPartnerPage />} />
        <Route path="locations" element={<LocationsPage />} />
        <Route path="locations/new" element={<CreateLocationPage />} />
        <Route path="balances" element={<BalancesPage />} />
        <Route path="balances/adjust" element={<AdjustStockPage />} />
        <Route path="movements" element={<MovementsPage />} />
        <Route path="sales-orders" element={<SalesOrdersPage />} />
        <Route path="sales-orders/new" element={<CreateSalesOrderPage />} />
        <Route path="sales-orders/:id" element={<SalesOrderDetailPage />} />
        <Route path="purchase-orders" element={<PurchaseOrdersPage />} />
        <Route path="purchase-orders/new" element={<CreatePurchaseOrderPage />} />
        <Route path="purchase-orders/:id" element={<PurchaseOrderDetailPage />} />
        <Route path="work-orders" element={<WorkOrdersPage />} />
        <Route path="work-orders/new" element={<CreateWorkOrderPage />} />
        <Route path="work-orders/:id" element={<WorkOrderDetailPage />} />
        <Route path="shop-floor" element={<ShopFloorPage />} />
        <Route path="accounts" element={<AccountsPage />} />
        <Route path="journal-entries" element={<JournalEntriesPage />} />
        <Route path="admin/metadata" element={<MetadataAdminPage />} />
        <Route path="admin/metadata/forms/new" element={<FormDesignerPage />} />
        <Route path="admin/metadata/forms/:slug/edit" element={<FormDesignerPage />} />
        <Route path="admin/metadata/list-views/new" element={<ListViewDesignerPage />} />
        <Route path="admin/metadata/list-views/:slug/edit" element={<ListViewDesignerPage />} />
      </Route>
      <Route path="*" element={<Navigate to="/" replace />} />
    </Routes>
  )
}
