Restructure async route code

This commit is contained in:
Bill Thornton 2022-11-01 16:41:09 -04:00
parent 20c33381f9
commit 2bc3bc8a93
5 changed files with 59 additions and 41 deletions

View file

@ -0,0 +1,10 @@
import { AsyncRoute } from '.';
export const ASYNC_ADMIN_ROUTES: AsyncRoute[] = [
{ path: 'usernew.html', page: 'user/usernew' },
{ path: 'userprofiles.html', page: 'user/userprofiles' },
{ path: 'useredit.html', page: 'user/useredit' },
{ path: 'userlibraryaccess.html', page: 'user/userlibraryaccess' },
{ path: 'userparentalcontrol.html', page: 'user/userparentalcontrol' },
{ path: 'userpassword.html', page: 'user/userpassword' }
];

View file

@ -0,0 +1,19 @@
import React from 'react';
import { Route } from 'react-router-dom';
import AsyncPage from '../../components/AsyncPage';
export interface AsyncRoute {
/** The URL path for this route. */
path: string
/** The relative path to the page component in the routes directory. */
page: string
}
export const toAsyncPageRoute = (route: AsyncRoute) => (
<Route
key={route.path}
path={route.path}
element={<AsyncPage page={route.page} />}
/>
);

View file

@ -0,0 +1,8 @@
import { AsyncRoute } from '.';
export const ASYNC_USER_ROUTES: AsyncRoute[] = [
{ path: 'search.html', page: 'search' },
{ path: 'userprofile.html', page: 'user/userprofile' },
{ path: 'home.html', page: 'home' },
{ path: 'movies.html', page: 'movies' }
];