diff --git a/src/App.css b/src/App.css index 805725c..fd1ff34 100644 --- a/src/App.css +++ b/src/App.css @@ -415,7 +415,7 @@ i { #index-page:before { display: block; margin-bottom: 0.5rem; - content: url('data:image/svg+xml,<%3Fxml version="1.0" encoding="UTF-8"%3F>'); + content: url('data:image/svg+xml,<%3Fxml version="1.0" encoding="UTF-8"%3F>'); } #error-page { diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index fbb0b29..6f7b71d 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -14,7 +14,8 @@ import { Route as rootRoute } from './routes/__root' import { Route as AboutImport } from './routes/about' import { Route as SidebarImport } from './routes/_sidebar' import { Route as SidebarIndexImport } from './routes/_sidebar/index' -import { Route as SidebarContactsContractIdImport } from './routes/_sidebar/contacts.$contractId' +import { Route as SidebarContactsImport } from './routes/_sidebar/contacts' +import { Route as SidebarContactsContactIdImport } from './routes/_sidebar/contacts.$contactId' // Create/Update Routes @@ -35,12 +36,18 @@ const SidebarIndexRoute = SidebarIndexImport.update({ getParentRoute: () => SidebarRoute, } as any) -const SidebarContactsContractIdRoute = SidebarContactsContractIdImport.update({ - id: '/contacts/$contractId', - path: '/contacts/$contractId', +const SidebarContactsRoute = SidebarContactsImport.update({ + id: '/contacts', + path: '/contacts', getParentRoute: () => SidebarRoute, } as any) +const SidebarContactsContactIdRoute = SidebarContactsContactIdImport.update({ + id: '/$contactId', + path: '/$contactId', + getParentRoute: () => SidebarContactsRoute, +} as any) + // Populate the FileRoutesByPath interface declare module '@tanstack/react-router' { @@ -59,6 +66,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof AboutImport parentRoute: typeof rootRoute } + '/_sidebar/contacts': { + id: '/_sidebar/contacts' + path: '/contacts' + fullPath: '/contacts' + preLoaderRoute: typeof SidebarContactsImport + parentRoute: typeof SidebarImport + } '/_sidebar/': { id: '/_sidebar/' path: '/' @@ -66,26 +80,38 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof SidebarIndexImport parentRoute: typeof SidebarImport } - '/_sidebar/contacts/$contractId': { - id: '/_sidebar/contacts/$contractId' - path: '/contacts/$contractId' - fullPath: '/contacts/$contractId' - preLoaderRoute: typeof SidebarContactsContractIdImport - parentRoute: typeof SidebarImport + '/_sidebar/contacts/$contactId': { + id: '/_sidebar/contacts/$contactId' + path: '/$contactId' + fullPath: '/contacts/$contactId' + preLoaderRoute: typeof SidebarContactsContactIdImport + parentRoute: typeof SidebarContactsImport } } } // Create and export the route tree +interface SidebarContactsRouteChildren { + SidebarContactsContactIdRoute: typeof SidebarContactsContactIdRoute +} + +const SidebarContactsRouteChildren: SidebarContactsRouteChildren = { + SidebarContactsContactIdRoute: SidebarContactsContactIdRoute, +} + +const SidebarContactsRouteWithChildren = SidebarContactsRoute._addFileChildren( + SidebarContactsRouteChildren, +) + interface SidebarRouteChildren { + SidebarContactsRoute: typeof SidebarContactsRouteWithChildren SidebarIndexRoute: typeof SidebarIndexRoute - SidebarContactsContractIdRoute: typeof SidebarContactsContractIdRoute } const SidebarRouteChildren: SidebarRouteChildren = { + SidebarContactsRoute: SidebarContactsRouteWithChildren, SidebarIndexRoute: SidebarIndexRoute, - SidebarContactsContractIdRoute: SidebarContactsContractIdRoute, } const SidebarRouteWithChildren = @@ -94,35 +120,39 @@ const SidebarRouteWithChildren = export interface FileRoutesByFullPath { '': typeof SidebarRouteWithChildren '/about': typeof AboutRoute + '/contacts': typeof SidebarContactsRouteWithChildren '/': typeof SidebarIndexRoute - '/contacts/$contractId': typeof SidebarContactsContractIdRoute + '/contacts/$contactId': typeof SidebarContactsContactIdRoute } export interface FileRoutesByTo { '/about': typeof AboutRoute + '/contacts': typeof SidebarContactsRouteWithChildren '/': typeof SidebarIndexRoute - '/contacts/$contractId': typeof SidebarContactsContractIdRoute + '/contacts/$contactId': typeof SidebarContactsContactIdRoute } export interface FileRoutesById { __root__: typeof rootRoute '/_sidebar': typeof SidebarRouteWithChildren '/about': typeof AboutRoute + '/_sidebar/contacts': typeof SidebarContactsRouteWithChildren '/_sidebar/': typeof SidebarIndexRoute - '/_sidebar/contacts/$contractId': typeof SidebarContactsContractIdRoute + '/_sidebar/contacts/$contactId': typeof SidebarContactsContactIdRoute } export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '' | '/about' | '/' | '/contacts/$contractId' + fullPaths: '' | '/about' | '/contacts' | '/' | '/contacts/$contactId' fileRoutesByTo: FileRoutesByTo - to: '/about' | '/' | '/contacts/$contractId' + to: '/about' | '/contacts' | '/' | '/contacts/$contactId' id: | '__root__' | '/_sidebar' | '/about' + | '/_sidebar/contacts' | '/_sidebar/' - | '/_sidebar/contacts/$contractId' + | '/_sidebar/contacts/$contactId' fileRoutesById: FileRoutesById } @@ -153,20 +183,27 @@ export const routeTree = rootRoute "/_sidebar": { "filePath": "_sidebar.tsx", "children": [ - "/_sidebar/", - "/_sidebar/contacts/$contractId" + "/_sidebar/contacts", + "/_sidebar/" ] }, "/about": { "filePath": "about.tsx" }, + "/_sidebar/contacts": { + "filePath": "_sidebar/contacts.tsx", + "parent": "/_sidebar", + "children": [ + "/_sidebar/contacts/$contactId" + ] + }, "/_sidebar/": { "filePath": "_sidebar/index.tsx", "parent": "/_sidebar" }, - "/_sidebar/contacts/$contractId": { - "filePath": "_sidebar/contacts.$contractId.tsx", - "parent": "/_sidebar" + "/_sidebar/contacts/$contactId": { + "filePath": "_sidebar/contacts.$contactId.tsx", + "parent": "/_sidebar/contacts" } } } diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 267adcb..f3b2484 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -23,7 +23,6 @@ export const Route = createRootRoute({ }] }), component: RootLayout, - notFoundComponent: NotFoundComponent, }); function RootLayout() { @@ -48,12 +47,3 @@ function RootDocument({ children }: Readonly<{ children: ReactNode }>) { ); } - -function NotFoundComponent() { - return ( -
-

404

-

The requested page could not be found.

-
- ); -} \ No newline at end of file diff --git a/src/routes/_sidebar.tsx b/src/routes/_sidebar.tsx index 73e38db..2f6a164 100644 --- a/src/routes/_sidebar.tsx +++ b/src/routes/_sidebar.tsx @@ -9,10 +9,16 @@ async function fetchContacts() { export const Route = createFileRoute('/_sidebar')({ component: Sidebar, loader: fetchContacts, + notFoundComponent: () =>
Not Found
, }); function Sidebar() { - const { contacts } = Route.useLoaderData(); + const cazzo = Route.useLoaderData(); + if (cazzo === undefined) { + console.log("SIDEBAR ERROR!?"); + return
CANE DIO SIDEBAR MORTE
; + } + const { contacts } = cazzo; return ( <> @@ -40,7 +46,7 @@ function Sidebar() {