import type { ComponentType, FC } from "react"; import { lazy } from "react"; import { Navigate, Route, Routes } from "react-router"; import { LazyPage } from "../RouteFallback"; import { Protected, Public } from "../RouteGuards"; // Pages use named exports; React.lazy needs a default export per dynamic import (one chunk each). function lazyPage( load: () => Promise>, name: Name, ) { return lazy(async () => { const page = await load(); // eslint-disable-next-line security/detect-object-injection -- `name` is a compile-time literal checked against the module's exports. return { default: page[name] }; }); } const CardPage = lazyPage(async () => import("@/pages/card"), "CardPage"); const CardsPage = lazyPage(async () => import("@/pages/cards"), "CardsPage"); const BondPage = lazyPage(async () => import("@/pages/bond"), "BondPage"); const BondsPage = lazyPage(async () => import("@/pages/bonds"), "BondsPage"); const StockPage = lazyPage(async () => import("@/pages/stock"), "StockPage"); const StocksPage = lazyPage(async () => import("@/pages/stocks"), "StocksPage"); const AccountPage = lazyPage(async () => import("@/pages/account"), "AccountPage"); const AccountEventsPage = lazyPage(async () => import("@/pages/account-events"), "AccountEventsPage"); const AccountOperationsPage = lazyPage(async () => import("@/pages/account-operations"), "AccountOperationsPage"); const AccountIncomePage = lazyPage(async () => import("@/pages/account-income"), "AccountIncomePage"); const AccountsPage = lazyPage(async () => import("@/pages/accounts"), "AccountsPage"); const LoginPage = lazyPage(async () => import("@/pages/login"), "LoginPage"); const NotFoundPage = lazyPage(async () => import("@/pages/not-found"), "NotFoundPage"); const RegisterPage = lazyPage(async () => import("@/pages/register"), "RegisterPage"); const SettingsPage = lazyPage(async () => import("@/pages/settings"), "SettingsPage"); const ProtectedLayout = lazyPage(async () => import("../ProtectedLayout"), "ProtectedLayout"); const AppRoutes: FC = () => ( } path="/" /> )} path="/login" /> )} path="/register" /> )} > )} path="/cards/:cardId" /> )} path="/cards" /> )} path="/bonds" /> )} path="/bonds/:bondId" /> )} path="/stocks" /> )} path="/stocks/:stockId" /> )} path="/accounts" /> )} path="/accounts/:accountId" /> )} path="/accounts/:accountId/events" /> )} path="/accounts/:accountId/income" /> )} path="/accounts/:accountId/operations" /> )} path="/settings" /> )} path="*" /> ); export { AppRoutes };