All files Router.tsx

75% Statements 6/8
100% Branches 0/0
66.66% Functions 4/6
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89                    3x           3x                                                                                               3x               15x                                
import { createRootRoute, createRoute, createRouter, RouterProvider } from '@tanstack/react-router';
import { ErrorBoundary } from './components/ErrorBoundary';
import { AboutPage } from './pages/About.page';
import { DashboardPage } from './pages/Dashboard.page';
import { HomePage } from './pages/Home.page';
import { Layout } from './pages/Layout';
import { SignupPage } from './pages/Signup.page';
import { ThreadedConversationPage } from './pages/ThreadedConversation.page';
 
const rootRoute = createRootRoute({
  component: Layout,
});
 
const homeRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: '/',
  component: HomePage,
});
 
const dashboardRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: 'dashboard',
  component: DashboardPage,
});
 
const conversationsRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: 'conversations',
  component: ThreadedConversationPage,
});
 
const aboutRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: 'about',
  component: AboutPage,
});
 
const signupRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: 'signup',
  component: SignupPage,
});
 
const routeTree = rootRoute.addChildren([
  homeRoute,
  dashboardRoute,
  conversationsRoute,
  aboutRoute,
  signupRoute,
  createPlaceholderRoute('analytics', 'Analytics', 'Analytics page content'),
  createPlaceholderRoute('releases', 'Releases', 'Releases page content'),
  createPlaceholderRoute('account', 'Account', 'Account page content'),
  createPlaceholderRoute('security', 'Security', 'Security page content'),
  createPlaceholderRoute('settings', 'Settings', 'Settings page content'),
]);
 
const router = createRouter({ routeTree });
 
declare module '@tanstack/react-router' {
  interface Register {
    router: typeof router;
  }
}
 
export function Router() {
  return (
    <ErrorBoundary context="Router">
      <RouterProvider router={router} />
    </ErrorBoundary>
  );
}
 
function createPlaceholderRoute(path: string, title: string, description: string) {
  return createRoute({
    getParentRoute: () => rootRoute,
    path,
    component: () => <PlaceholderPage title={title} description={description} />,
  });
}
 
function PlaceholderPage({ title, description }: { title: string; description: string }) {
  return (
    <div>
      <h1>{title}</h1>
      <p>{description}</p>
    </div>
  );
}