Refactor asyncRouteType to appType
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import type { RouteObject } from 'react-router-dom';
|
||||
|
||||
export enum AsyncRouteType {
|
||||
Stable,
|
||||
Experimental,
|
||||
Dashboard
|
||||
}
|
||||
import { AppType } from 'constants/appType';
|
||||
|
||||
export interface AsyncRoute {
|
||||
/** The URL path for this route. */
|
||||
@@ -14,25 +10,18 @@ export interface AsyncRoute {
|
||||
* Will fallback to using the `path` value if not specified.
|
||||
*/
|
||||
page?: string
|
||||
/** The page type used to load the correct page element. */
|
||||
type?: AsyncRouteType
|
||||
/** The app that this page is part of. */
|
||||
type?: AppType
|
||||
}
|
||||
|
||||
const importRoute = (page: string, type: AsyncRouteType) => {
|
||||
switch (type) {
|
||||
case AsyncRouteType.Dashboard:
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/dashboard/routes/${page}`);
|
||||
case AsyncRouteType.Experimental:
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/experimental/routes/${page}`);
|
||||
case AsyncRouteType.Stable:
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/stable/routes/${page}`);
|
||||
}
|
||||
const importRoute = (page: string, type: AppType) => {
|
||||
return import(/* webpackChunkName: "[request]" */ `../../apps/${type}/routes/${page}`);
|
||||
};
|
||||
|
||||
export const toAsyncPageRoute = ({
|
||||
path,
|
||||
page,
|
||||
type = AsyncRouteType.Stable
|
||||
type = AppType.Stable
|
||||
}: AsyncRoute): RouteObject => {
|
||||
return {
|
||||
path,
|
||||
|
||||
Reference in New Issue
Block a user