/** * Application Routes * @description Defines public and authenticated routes using TanStack Router. */ import { createRootRoute, createRoute, createRouter, Outlet } from '@tanstack/react-router'; import { RootLayout } from '@/components/layout'; import { AgentPage } from '@/pages/agent'; import { AgentCreatePage } from '@/pages/agent-create'; import { Dashboard } from '@/pages/dashboard'; import { SignUpPage } from '@/pages/sign-up'; import { LoginPage } from '@/pages/login-page'; export const APP_PATHS = { signIn: '/', signUp: '/signup', dashboard: '/dashboard', agent: '/agent', agentCreate: '/agent/create', } as const; const rootRoute = createRootRoute({ component: () => , }); const publicRoute = createRoute({ getParentRoute: () => rootRoute, id: 'public', component: () => , }); const appRoute = createRoute({ getParentRoute: () => rootRoute, id: 'app', component: () => ( ), }); const loginRoute = createRoute({ getParentRoute: () => publicRoute, path: '/', component: LoginPage, }); const signUpRoute = createRoute({ getParentRoute: () => publicRoute, path: APP_PATHS.signUp, component: SignUpPage, }); const dashboardRoute = createRoute({ getParentRoute: () => appRoute, path: APP_PATHS.dashboard, component: Dashboard, }); const agentRoute = createRoute({ getParentRoute: () => appRoute, path: APP_PATHS.agent, component: AgentPage, }); const agentCreateRoute = createRoute({ getParentRoute: () => appRoute, path: APP_PATHS.agentCreate, component: AgentCreatePage, }); const notFoundRoute = createRoute({ getParentRoute: () => rootRoute, path: '*', component: () => (

Page not found

The page you requested does not exist.

), }); const routeTree = rootRoute.addChildren([ publicRoute.addChildren([loginRoute, signUpRoute]), appRoute.addChildren([dashboardRoute,agentRoute,agentCreateRoute,notFoundRoute]), ]); export const router = createRouter({ routeTree, defaultPreload: 'intent', }); declare module '@tanstack/react-router' { interface Register { router: typeof router; } }