import { lazy, Suspense } from "react"; import { createBrowserRouter, Navigate, Outlet } from "react-router-dom"; import { useAuthStore } from "../store/authStore"; import { Spinner } from "@/components/ui/spinner"; import { DashboardLayout } from "@/layouts/DashboardLayout"; const LoginPage = lazy(() => import("@/pages/login")); const DashboardPage = lazy(() => import("@/pages/dashboard")); const LoanOrdersPage = lazy(() => import("@/pages/loanOrders")); const LoanOrderMobilesPage = lazy(() => import("@/pages/loanOrderMobiles")); const LoanRemainingPage = lazy(() => import("@/pages/loanRemaining")); const LoanPaidOffLettersPage = lazy(() => import("@/pages/loanPaidOffLetters")); const LoanOrderCreatePage = lazy(() => import("@/pages/loanOrderCreate")); const LoanOrderViewPage = lazy(() => import("@/pages/loanOrderView")); function AuthGuard() { const isAuthenticated = useAuthStore((s) => s.isAuthenticated); if (!isAuthenticated) return ; return ; } function PublicGuard() { const isAuthenticated = useAuthStore((s) => s.isAuthenticated); if (isAuthenticated) return ; return ; } function PageLoader() { return (
); } export const router = createBrowserRouter([ { element: , children: [ { path: "/login", element: ( }> ), }, ], }, { element: , children: [ { element: , children: [ { path: "/dashboard", element: ( }> ), }, { path: "/", element: }, // ── KARZ BÖLÜMI ────────────────────────────────────────────────── { path: "/loan-orders", element: ( }> ), }, { path: "/loan-orders/:id", element: ( }> ), }, { path: "/loan-orders/create", element: ( }> ), }, { // Sidebar: /loan-order-mobiles path: "/loan-order-mobiles", element: ( }> ), }, { // Sidebar: /loan-remaining path: "/loan-remaining", element: ( }> ), }, { // Sidebar: /loan-paid-off-letters path: "/loan-paid-off-letters", element: ( }> ), }, ], }, ], }, { path: "*", element: , }, ]);