101 lines
2.5 KiB
TypeScript
101 lines
2.5 KiB
TypeScript
/**
|
|
* 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: () => <Outlet />,
|
|
});
|
|
|
|
const publicRoute = createRoute({
|
|
getParentRoute: () => rootRoute,
|
|
id: 'public',
|
|
component: () => <Outlet />,
|
|
});
|
|
|
|
const appRoute = createRoute({
|
|
getParentRoute: () => rootRoute,
|
|
id: 'app',
|
|
component: () => (
|
|
<RootLayout>
|
|
<Outlet />
|
|
</RootLayout>
|
|
),
|
|
});
|
|
|
|
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: () => (
|
|
<div className="px-8 pt-8">
|
|
<div className="rounded-2xl border border-gray-200 bg-white/90 p-8 shadow-sm">
|
|
<h1 className="text-xl font-semibold text-gray-900">Page not found</h1>
|
|
<p className="mt-2 text-sm text-gray-600">The page you requested does not exist.</p>
|
|
</div>
|
|
</div>
|
|
),
|
|
});
|
|
|
|
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;
|
|
}
|
|
}
|
|
|