Explicitly annotated type of router in main.tsx. Added recipe edit route.
This commit is contained in:
parent
e237ea89ee
commit
e328b64043
@ -1,6 +1,6 @@
|
|||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { fas } from '@fortawesome/free-solid-svg-icons'
|
import { fas } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { RouterProvider, createRouter } from '@tanstack/react-router'
|
import { Router, RouterProvider, createRouter } from '@tanstack/react-router'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom/client'
|
import ReactDOM from 'react-dom/client'
|
||||||
import { AuthProvider, useAuth } from './auth'
|
import { AuthProvider, useAuth } from './auth'
|
||||||
@ -12,8 +12,8 @@ import { routeTree } from './routeTree.gen'
|
|||||||
library.add(fas)
|
library.add(fas)
|
||||||
|
|
||||||
// Create router
|
// Create router
|
||||||
// Must be `any` because TS complains otherwise
|
// Type must be explicitly annotated otherwise TS complains
|
||||||
const router: any = createRouter({
|
const router: Router<typeof routeTree, 'preserve'> = createRouter({
|
||||||
context: {
|
context: {
|
||||||
auth: undefined!
|
auth: undefined!
|
||||||
},
|
},
|
||||||
|
@ -16,6 +16,7 @@ import { Route as LoginImport } from './routes/login'
|
|||||||
import { Route as AuthImport } from './routes/_auth'
|
import { Route as AuthImport } from './routes/_auth'
|
||||||
import { Route as AuthIndexImport } from './routes/_auth/index'
|
import { Route as AuthIndexImport } from './routes/_auth/index'
|
||||||
import { Route as RecipesUsernameSlugImport } from './routes/recipes_/$username.$slug'
|
import { Route as RecipesUsernameSlugImport } from './routes/recipes_/$username.$slug'
|
||||||
|
import { Route as RecipesUsernameSlugEditImport } from './routes/recipes_/$username.$slug_/edit'
|
||||||
|
|
||||||
// Create/Update Routes
|
// Create/Update Routes
|
||||||
|
|
||||||
@ -44,6 +45,11 @@ const RecipesUsernameSlugRoute = RecipesUsernameSlugImport.update({
|
|||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
|
const RecipesUsernameSlugEditRoute = RecipesUsernameSlugEditImport.update({
|
||||||
|
path: '/recipes/$username/$slug/edit',
|
||||||
|
getParentRoute: () => rootRoute,
|
||||||
|
} as any)
|
||||||
|
|
||||||
// Populate the FileRoutesByPath interface
|
// Populate the FileRoutesByPath interface
|
||||||
|
|
||||||
declare module '@tanstack/react-router' {
|
declare module '@tanstack/react-router' {
|
||||||
@ -83,6 +89,13 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof RecipesUsernameSlugImport
|
preLoaderRoute: typeof RecipesUsernameSlugImport
|
||||||
parentRoute: typeof rootRoute
|
parentRoute: typeof rootRoute
|
||||||
}
|
}
|
||||||
|
'/recipes/$username/$slug/edit': {
|
||||||
|
id: '/recipes/$username/$slug/edit'
|
||||||
|
path: '/recipes/$username/$slug/edit'
|
||||||
|
fullPath: '/recipes/$username/$slug/edit'
|
||||||
|
preLoaderRoute: typeof RecipesUsernameSlugEditImport
|
||||||
|
parentRoute: typeof rootRoute
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +106,7 @@ export const routeTree = rootRoute.addChildren({
|
|||||||
LoginRoute,
|
LoginRoute,
|
||||||
RecipesRoute,
|
RecipesRoute,
|
||||||
RecipesUsernameSlugRoute,
|
RecipesUsernameSlugRoute,
|
||||||
|
RecipesUsernameSlugEditRoute,
|
||||||
})
|
})
|
||||||
|
|
||||||
/* prettier-ignore-end */
|
/* prettier-ignore-end */
|
||||||
@ -106,7 +120,8 @@ export const routeTree = rootRoute.addChildren({
|
|||||||
"/_auth",
|
"/_auth",
|
||||||
"/login",
|
"/login",
|
||||||
"/recipes",
|
"/recipes",
|
||||||
"/recipes/$username/$slug"
|
"/recipes/$username/$slug",
|
||||||
|
"/recipes/$username/$slug/edit"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"/_auth": {
|
"/_auth": {
|
||||||
@ -127,6 +142,9 @@ export const routeTree = rootRoute.addChildren({
|
|||||||
},
|
},
|
||||||
"/recipes/$username/$slug": {
|
"/recipes/$username/$slug": {
|
||||||
"filePath": "recipes_/$username.$slug.tsx"
|
"filePath": "recipes_/$username.$slug.tsx"
|
||||||
|
},
|
||||||
|
"/recipes/$username/$slug/edit": {
|
||||||
|
"filePath": "recipes_/$username.$slug_/edit.tsx"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
src/routes/recipes_/$username.$slug_/edit.tsx
Normal file
5
src/routes/recipes_/$username.$slug_/edit.tsx
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
export const Route = createFileRoute('/recipes/$username/$slug/edit')({
|
||||||
|
component: () => <div>Hello /recipes/$username/$slug/edit!</div>
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user