Update routing for admin channels and shows: add index routes for channels and shows, refactor components to use Outlet for nested routing, and enhance type definitions for new routes in the routing structure.

This commit is contained in:
Leonid Pershin
2026-07-24 19:08:17 +03:00
parent b7cdc4ad96
commit 8281832e1d
5 changed files with 56 additions and 10 deletions
+42 -4
View File
@@ -21,7 +21,9 @@ import { Route as AdminMediaRouteImport } from './routes/admin/media'
import { Route as AdminRolesRouteImport } from './routes/admin/roles' import { Route as AdminRolesRouteImport } from './routes/admin/roles'
import { Route as AdminShowsRouteImport } from './routes/admin/shows' import { Route as AdminShowsRouteImport } from './routes/admin/shows'
import { Route as AdminUsersRouteImport } from './routes/admin/users' import { Route as AdminUsersRouteImport } from './routes/admin/users'
import { Route as AdminChannelsIndexRouteImport } from './routes/admin/channels.index'
import { Route as AdminChannelsChannelIdRouteImport } from './routes/admin/channels.$channelId' import { Route as AdminChannelsChannelIdRouteImport } from './routes/admin/channels.$channelId'
import { Route as AdminShowsIndexRouteImport } from './routes/admin/shows.index'
import { Route as AdminShowsShowIdRouteImport } from './routes/admin/shows.$showId' import { Route as AdminShowsShowIdRouteImport } from './routes/admin/shows.$showId'
const IndexRoute = IndexRouteImport.update({ const IndexRoute = IndexRouteImport.update({
@@ -84,11 +86,21 @@ const AdminUsersRoute = AdminUsersRouteImport.update({
path: '/users', path: '/users',
getParentRoute: () => AdminRoute, getParentRoute: () => AdminRoute,
} as any) } as any)
const AdminChannelsIndexRoute = AdminChannelsIndexRouteImport.update({
id: '/',
path: '/',
getParentRoute: () => AdminChannelsRoute,
} as any)
const AdminChannelsChannelIdRoute = AdminChannelsChannelIdRouteImport.update({ const AdminChannelsChannelIdRoute = AdminChannelsChannelIdRouteImport.update({
id: '/$channelId', id: '/$channelId',
path: '/$channelId', path: '/$channelId',
getParentRoute: () => AdminChannelsRoute, getParentRoute: () => AdminChannelsRoute,
} as any) } as any)
const AdminShowsIndexRoute = AdminShowsIndexRouteImport.update({
id: '/',
path: '/',
getParentRoute: () => AdminShowsRoute,
} as any)
const AdminShowsShowIdRoute = AdminShowsShowIdRouteImport.update({ const AdminShowsShowIdRoute = AdminShowsShowIdRouteImport.update({
id: '/$showId', id: '/$showId',
path: '/$showId', path: '/$showId',
@@ -110,6 +122,8 @@ export interface FileRoutesByFullPath {
'/admin/': typeof AdminIndexRoute '/admin/': typeof AdminIndexRoute
'/admin/channels/$channelId': typeof AdminChannelsChannelIdRoute '/admin/channels/$channelId': typeof AdminChannelsChannelIdRoute
'/admin/shows/$showId': typeof AdminShowsShowIdRoute '/admin/shows/$showId': typeof AdminShowsShowIdRoute
'/admin/channels/': typeof AdminChannelsIndexRoute
'/admin/shows/': typeof AdminShowsIndexRoute
} }
export interface FileRoutesByTo { export interface FileRoutesByTo {
'/': typeof IndexRoute '/': typeof IndexRoute
@@ -117,14 +131,14 @@ export interface FileRoutesByTo {
'/login': typeof LoginRoute '/login': typeof LoginRoute
'/register': typeof RegisterRoute '/register': typeof RegisterRoute
'/settings': typeof SettingsRoute '/settings': typeof SettingsRoute
'/admin/channels': typeof AdminChannelsRouteWithChildren
'/admin/media': typeof AdminMediaRoute '/admin/media': typeof AdminMediaRoute
'/admin/roles': typeof AdminRolesRoute '/admin/roles': typeof AdminRolesRoute
'/admin/shows': typeof AdminShowsRouteWithChildren
'/admin/users': typeof AdminUsersRoute '/admin/users': typeof AdminUsersRoute
'/admin': typeof AdminIndexRoute '/admin': typeof AdminIndexRoute
'/admin/channels/$channelId': typeof AdminChannelsChannelIdRoute '/admin/channels/$channelId': typeof AdminChannelsChannelIdRoute
'/admin/shows/$showId': typeof AdminShowsShowIdRoute '/admin/shows/$showId': typeof AdminShowsShowIdRoute
'/admin/channels': typeof AdminChannelsIndexRoute
'/admin/shows': typeof AdminShowsIndexRoute
} }
export interface FileRoutesById { export interface FileRoutesById {
__root__: typeof rootRouteImport __root__: typeof rootRouteImport
@@ -142,6 +156,8 @@ export interface FileRoutesById {
'/admin/': typeof AdminIndexRoute '/admin/': typeof AdminIndexRoute
'/admin/channels/$channelId': typeof AdminChannelsChannelIdRoute '/admin/channels/$channelId': typeof AdminChannelsChannelIdRoute
'/admin/shows/$showId': typeof AdminShowsShowIdRoute '/admin/shows/$showId': typeof AdminShowsShowIdRoute
'/admin/channels/': typeof AdminChannelsIndexRoute
'/admin/shows/': typeof AdminShowsIndexRoute
} }
export interface FileRouteTypes { export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath fileRoutesByFullPath: FileRoutesByFullPath
@@ -160,6 +176,8 @@ export interface FileRouteTypes {
| '/admin/' | '/admin/'
| '/admin/channels/$channelId' | '/admin/channels/$channelId'
| '/admin/shows/$showId' | '/admin/shows/$showId'
| '/admin/channels/'
| '/admin/shows/'
fileRoutesByTo: FileRoutesByTo fileRoutesByTo: FileRoutesByTo
to: to:
| '/' | '/'
@@ -167,14 +185,14 @@ export interface FileRouteTypes {
| '/login' | '/login'
| '/register' | '/register'
| '/settings' | '/settings'
| '/admin/channels'
| '/admin/media' | '/admin/media'
| '/admin/roles' | '/admin/roles'
| '/admin/shows'
| '/admin/users' | '/admin/users'
| '/admin' | '/admin'
| '/admin/channels/$channelId' | '/admin/channels/$channelId'
| '/admin/shows/$showId' | '/admin/shows/$showId'
| '/admin/channels'
| '/admin/shows'
id: id:
| '__root__' | '__root__'
| '/' | '/'
@@ -191,6 +209,8 @@ export interface FileRouteTypes {
| '/admin/' | '/admin/'
| '/admin/channels/$channelId' | '/admin/channels/$channelId'
| '/admin/shows/$showId' | '/admin/shows/$showId'
| '/admin/channels/'
| '/admin/shows/'
fileRoutesById: FileRoutesById fileRoutesById: FileRoutesById
} }
export interface RootRouteChildren { export interface RootRouteChildren {
@@ -288,6 +308,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AdminUsersRouteImport preLoaderRoute: typeof AdminUsersRouteImport
parentRoute: typeof AdminRoute parentRoute: typeof AdminRoute
} }
'/admin/channels/': {
id: '/admin/channels/'
path: '/'
fullPath: '/admin/channels/'
preLoaderRoute: typeof AdminChannelsIndexRouteImport
parentRoute: typeof AdminChannelsRoute
}
'/admin/channels/$channelId': { '/admin/channels/$channelId': {
id: '/admin/channels/$channelId' id: '/admin/channels/$channelId'
path: '/$channelId' path: '/$channelId'
@@ -295,6 +322,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AdminChannelsChannelIdRouteImport preLoaderRoute: typeof AdminChannelsChannelIdRouteImport
parentRoute: typeof AdminChannelsRoute parentRoute: typeof AdminChannelsRoute
} }
'/admin/shows/': {
id: '/admin/shows/'
path: '/'
fullPath: '/admin/shows/'
preLoaderRoute: typeof AdminShowsIndexRouteImport
parentRoute: typeof AdminShowsRoute
}
'/admin/shows/$showId': { '/admin/shows/$showId': {
id: '/admin/shows/$showId' id: '/admin/shows/$showId'
path: '/$showId' path: '/$showId'
@@ -307,10 +341,12 @@ declare module '@tanstack/react-router' {
interface AdminChannelsRouteChildren { interface AdminChannelsRouteChildren {
AdminChannelsChannelIdRoute: typeof AdminChannelsChannelIdRoute AdminChannelsChannelIdRoute: typeof AdminChannelsChannelIdRoute
AdminChannelsIndexRoute: typeof AdminChannelsIndexRoute
} }
const AdminChannelsRouteChildren: AdminChannelsRouteChildren = { const AdminChannelsRouteChildren: AdminChannelsRouteChildren = {
AdminChannelsChannelIdRoute: AdminChannelsChannelIdRoute, AdminChannelsChannelIdRoute: AdminChannelsChannelIdRoute,
AdminChannelsIndexRoute: AdminChannelsIndexRoute,
} }
const AdminChannelsRouteWithChildren = AdminChannelsRoute._addFileChildren( const AdminChannelsRouteWithChildren = AdminChannelsRoute._addFileChildren(
@@ -319,10 +355,12 @@ const AdminChannelsRouteWithChildren = AdminChannelsRoute._addFileChildren(
interface AdminShowsRouteChildren { interface AdminShowsRouteChildren {
AdminShowsShowIdRoute: typeof AdminShowsShowIdRoute AdminShowsShowIdRoute: typeof AdminShowsShowIdRoute
AdminShowsIndexRoute: typeof AdminShowsIndexRoute
} }
const AdminShowsRouteChildren: AdminShowsRouteChildren = { const AdminShowsRouteChildren: AdminShowsRouteChildren = {
AdminShowsShowIdRoute: AdminShowsShowIdRoute, AdminShowsShowIdRoute: AdminShowsShowIdRoute,
AdminShowsIndexRoute: AdminShowsIndexRoute,
} }
const AdminShowsRouteWithChildren = AdminShowsRoute._addFileChildren( const AdminShowsRouteWithChildren = AdminShowsRoute._addFileChildren(
@@ -0,0 +1,4 @@
import { createFileRoute } from '@tanstack/react-router'
import { ChannelsPanel } from '@/features/admin/channels/ChannelsPanel'
export const Route = createFileRoute('/admin/channels/')({ component: ChannelsPanel })
+3 -3
View File
@@ -1,4 +1,4 @@
import { createFileRoute } from '@tanstack/react-router' import { createFileRoute, Outlet } from '@tanstack/react-router'
import { ChannelsPanel } from '@/features/admin/channels/ChannelsPanel'
export const Route = createFileRoute('/admin/channels')({ component: ChannelsPanel }) // Лейаут для /admin/channels/*: список — в index-роуте, деталь — в channels.$channelId.
export const Route = createFileRoute('/admin/channels')({ component: () => <Outlet /> })
@@ -0,0 +1,4 @@
import { createFileRoute } from '@tanstack/react-router'
import { ShowsPanel } from '@/features/admin/shows/ShowsPanel'
export const Route = createFileRoute('/admin/shows/')({ component: ShowsPanel })
+3 -3
View File
@@ -1,4 +1,4 @@
import { createFileRoute } from '@tanstack/react-router' import { createFileRoute, Outlet } from '@tanstack/react-router'
import { ShowsPanel } from '@/features/admin/shows/ShowsPanel'
export const Route = createFileRoute('/admin/shows')({ component: ShowsPanel }) // Лейаут для /admin/shows/*: список — в index-роуте, деталь — в shows.$showId.
export const Route = createFileRoute('/admin/shows')({ component: () => <Outlet /> })