import { lazy, Suspense } from "react"; import { Routes, Route } from "react-router-dom"; import { QueryClientProvider } from "@tanstack/react-query"; import { AuthProvider } from "./context/AuthContext"; import { AlertProvider } from "./context/AlertContext"; import { queryClient } from "./lib/queryClient"; import ErrorBoundary from "./components/ErrorBoundary"; import AppShell from "./ui/AppShell"; import AlertContainer from "./components/AlertContainer"; import UpdateBanner from "./components/UpdateBanner"; import { lazyWithReload } from "./utils/lazyWithReload"; import MuiProvider from "./ui/MuiProvider"; import { LoadingState } from "./ui"; import Login from "./pages/Login"; const Dashboard = lazyWithReload(() => import("./pages/Dashboard")); const Odin = lazyWithReload(() => import("./pages/Odin")); const Users = lazyWithReload(() => import("./pages/Users")); const Attendance = lazyWithReload(() => import("./pages/Attendance")); const AttendanceHistory = lazyWithReload( () => import("./pages/AttendanceHistory"), ); const AttendanceAdmin = lazyWithReload(() => import("./pages/AttendanceAdmin")); const AttendanceBalances = lazyWithReload( () => import("./pages/AttendanceBalances"), ); const AttendanceCreate = lazyWithReload( () => import("./pages/AttendanceCreate"), ); const LeaveRequests = lazyWithReload(() => import("./pages/LeaveRequests")); const LeaveApproval = lazyWithReload(() => import("./pages/LeaveApproval")); const AttendanceLocation = lazyWithReload( () => import("./pages/AttendanceLocation"), ); const PlanWork = lazyWithReload(() => import("./pages/PlanWork")); const Trips = lazyWithReload(() => import("./pages/Trips")); const TripsHistory = lazyWithReload(() => import("./pages/TripsHistory")); const TripsAdmin = lazyWithReload(() => import("./pages/TripsAdmin")); const Vehicles = lazyWithReload(() => import("./pages/Vehicles")); const Offers = lazyWithReload(() => import("./pages/Offers")); const OfferDetail = lazyWithReload(() => import("./pages/OfferDetail")); const OffersCustomers = lazyWithReload(() => import("./pages/OffersCustomers")); const OffersTemplates = lazyWithReload(() => import("./pages/OffersTemplates")); const Orders = lazyWithReload(() => import("./pages/Orders")); const OrderDetail = lazyWithReload(() => import("./pages/OrderDetail")); const IssuedOrderDetail = lazyWithReload( () => import("./pages/IssuedOrderDetail"), ); const Projects = lazyWithReload(() => import("./pages/Projects")); const ProjectDetail = lazyWithReload(() => import("./pages/ProjectDetail")); const Invoices = lazyWithReload(() => import("./pages/Invoices")); const InvoiceDetail = lazyWithReload(() => import("./pages/InvoiceDetail")); const Settings = lazyWithReload(() => import("./pages/Settings")); const AuditLog = lazyWithReload(() => import("./pages/AuditLog")); const NotFound = lazyWithReload(() => import("./pages/NotFound")); const Warehouse = lazyWithReload(() => import("./pages/Warehouse")); const WarehouseItems = lazyWithReload(() => import("./pages/WarehouseItems")); const WarehouseItemDetail = lazyWithReload( () => import("./pages/WarehouseItemDetail"), ); const WarehouseReceipts = lazyWithReload( () => import("./pages/WarehouseReceipts"), ); const WarehouseReceiptDetail = lazyWithReload( () => import("./pages/WarehouseReceiptDetail"), ); const WarehouseReceiptForm = lazyWithReload( () => import("./pages/WarehouseReceiptForm"), ); const WarehouseIssues = lazyWithReload(() => import("./pages/WarehouseIssues")); const WarehouseIssueDetail = lazyWithReload( () => import("./pages/WarehouseIssueDetail"), ); const WarehouseIssueForm = lazyWithReload( () => import("./pages/WarehouseIssueForm"), ); const WarehouseReservations = lazyWithReload( () => import("./pages/WarehouseReservations"), ); const WarehouseInventory = lazyWithReload( () => import("./pages/WarehouseInventory"), ); const WarehouseInventoryDetail = lazyWithReload( () => import("./pages/WarehouseInventoryDetail"), ); const WarehouseInventoryForm = lazyWithReload( () => import("./pages/WarehouseInventoryForm"), ); const WarehouseReports = lazyWithReload( () => import("./pages/WarehouseReports"), ); const WarehouseSuppliers = lazyWithReload( () => import("./pages/WarehouseSuppliers"), ); const WarehouseLocations = lazyWithReload( () => import("./pages/WarehouseLocations"), ); const WarehouseCategories = lazyWithReload( () => import("./pages/WarehouseCategories"), ); const UiKit = import.meta.env.DEV ? lazy(() => import("./pages/UiKit")) : null; export default function AdminApp() { return ( }> } /> {import.meta.env.DEV && UiKit && ( } /> )} {/* Auth gating is delegated to : every authenticated page is nested under this layout route, and AppShell redirects to /login when there is no user (per-page permission checks live in the pages themselves). NOTE: any NEW top-level route added OUTSIDE this wrapper (like `login`/`ui-kit` above) is PUBLIC by default — wrap it in AppShell or add its own guard if it needs auth. */} }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); }