From 1323cfbf91c0f714b4c35e4815729fff34bdcefb Mon Sep 17 00:00:00 2001 From: redglow Date: Sat, 20 Jun 2026 16:34:59 +0200 Subject: [PATCH] base layout --- src/client/components/DashboardLayout.tsx | 58 ++++++++++++----------- src/client/routeTree.gen.ts | 44 +++++++++++++---- src/client/routes/index.tsx | 9 ++++ 3 files changed, 73 insertions(+), 38 deletions(-) create mode 100644 src/client/routes/index.tsx diff --git a/src/client/components/DashboardLayout.tsx b/src/client/components/DashboardLayout.tsx index 444d0f2..e28bbac 100644 --- a/src/client/components/DashboardLayout.tsx +++ b/src/client/components/DashboardLayout.tsx @@ -8,10 +8,19 @@ import { Toolbar, Typography, } from "@mui/material"; +import { useNavigate } from "@tanstack/react-router"; import { useState } from "react"; +import type { FileRouteTypes } from "../routeTree.gen"; import { RouterButton } from "./RouterButton"; -const pages = ["Products", "Pricing", "Blog"]; +type ValidRoutes = FileRouteTypes["to"]; + +interface Page { + title: string; + to: ValidRoutes; +} + +const pages: Page[] = [{ title: "Announcements", to: "/" }]; export default function DashboardLayout({ children, @@ -28,16 +37,10 @@ export default function DashboardLayout({ setAnchorElNav(null); }; + const navigate = useNavigate(); + return ( - + {/* desktop */} @@ -78,8 +81,16 @@ export default function DashboardLayout({ sx={{ display: { xs: "block", md: "none" } }} > {pages.map((page) => ( - - {page} + { + handleCloseNavMenu(); + navigate({ to: page.to }); + }} + > + + {page.title} + ))} @@ -96,37 +107,28 @@ export default function DashboardLayout({ {pages.map((page) => ( - {page} + {page.title} ))} - - - {children} - + {children} ); diff --git a/src/client/routeTree.gen.ts b/src/client/routeTree.gen.ts index d9b0e2b..d204c26 100644 --- a/src/client/routeTree.gen.ts +++ b/src/client/routeTree.gen.ts @@ -9,27 +9,51 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' +import { Route as IndexRouteImport } from './routes/index' -export interface FileRoutesByFullPath {} -export interface FileRoutesByTo {} +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => rootRouteImport, +} as any) + +export interface FileRoutesByFullPath { + '/': typeof IndexRoute +} +export interface FileRoutesByTo { + '/': typeof IndexRoute +} export interface FileRoutesById { __root__: typeof rootRouteImport + '/': typeof IndexRoute } export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: never + fullPaths: '/' fileRoutesByTo: FileRoutesByTo - to: never - id: '__root__' + to: '/' + id: '__root__' | '/' fileRoutesById: FileRoutesById } -export interface RootRouteChildren {} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath {} +export interface RootRouteChildren { + IndexRoute: typeof IndexRoute } -const rootRouteChildren: RootRouteChildren = {} +declare module '@tanstack/react-router' { + interface FileRoutesByPath { + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport + } + } +} + +const rootRouteChildren: RootRouteChildren = { + IndexRoute: IndexRoute, +} export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) ._addFileTypes() diff --git a/src/client/routes/index.tsx b/src/client/routes/index.tsx new file mode 100644 index 0000000..3bbfc9a --- /dev/null +++ b/src/client/routes/index.tsx @@ -0,0 +1,9 @@ +import { createFileRoute } from "@tanstack/react-router"; + +export const Route = createFileRoute("/")({ + component: RouteComponent, +}); + +function RouteComponent() { + return
Hello "/"!
; +}