Co-Authored-By: Claude Haiku 4.5 <[email protected]>
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import type { ReactElement } from 'react';
|
|
import { createBrowserRouter, Navigate, Outlet, type RouteObject } from 'react-router-dom';
|
|
import { LoginPage } from '@/spa/pages/login';
|
|
import { RegisterPage } from '@/spa/pages/register';
|
|
import { SsoCallbackPage } from '@/spa/pages/sso-callback';
|
|
import { ChatPage } from '@/spa/pages/chat';
|
|
import { ChatRouteErrorBoundary } from '@/spa/pages/chat-error-boundary';
|
|
import { AuthGuard, GuestGuard } from '@/spa/guards';
|
|
import { Placeholder } from '@/spa/placeholder';
|
|
|
|
function GuestLayout(): ReactElement {
|
|
return (
|
|
<div className="flex min-h-screen items-center justify-center bg-surface-bg px-4 py-8">
|
|
<div className="w-full max-w-md rounded-xl border border-surface-border bg-surface-card p-8 shadow-lg">
|
|
<Outlet />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export const routes: RouteObject[] = [
|
|
{
|
|
element: <GuestGuard />,
|
|
children: [
|
|
{
|
|
element: <GuestLayout />,
|
|
children: [
|
|
{ path: '/login', element: <LoginPage /> },
|
|
{ path: '/register', element: <RegisterPage /> },
|
|
{ path: '/auth/provider/:provider', element: <SsoCallbackPage /> },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
element: <AuthGuard />,
|
|
children: [
|
|
{ path: '/', element: <Navigate to="/chat" replace /> },
|
|
{ path: '/chat', element: <ChatPage />, errorElement: <ChatRouteErrorBoundary /> },
|
|
{ path: '/projects', element: <Placeholder title="Projects" /> },
|
|
{ path: '/projects/:id', element: <Placeholder title="Project" /> },
|
|
{ path: '/tasks', element: <Placeholder title="Tasks" /> },
|
|
{ path: '/settings', element: <Placeholder title="Settings" /> },
|
|
{ path: '/admin', element: <Placeholder title="Admin" /> },
|
|
],
|
|
},
|
|
];
|
|
|
|
export function createAppRouter(): ReturnType<typeof createBrowserRouter> {
|
|
return createBrowserRouter(routes);
|
|
}
|