feat routes
: Make routes work even if there are none.
This commit is contained in:
parent
1adf071d2e
commit
60e57f1f5f
3 changed files with 18 additions and 8 deletions
|
@ -23,7 +23,7 @@ export const NavigationLinks = () => {
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* Blueprint routes */}
|
{/* Blueprint routes */}
|
||||||
{blueprintRoutes.account
|
{blueprintRoutes.account.length > 0 && blueprintRoutes.account
|
||||||
.filter((route) => !!route.name)
|
.filter((route) => !!route.name)
|
||||||
.map(({ path, name, exact = false }) => (
|
.map(({ path, name, exact = false }) => (
|
||||||
<NavLink key={path} to={`/account/${path}`.replace('//', '/')} exact={exact}>
|
<NavLink key={path} to={`/account/${path}`.replace('//', '/')} exact={exact}>
|
||||||
|
@ -54,7 +54,7 @@ export const NavigationRouter = () => {
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* Blueprint routes */}
|
{/* Blueprint routes */}
|
||||||
{blueprintRoutes.account.map(({ path, component: Component }) => (
|
{blueprintRoutes.account.length > 0 && blueprintRoutes.account.map(({ path, component: Component }) => (
|
||||||
<Route key={path} path={`/account/${path}`.replace('//', '/')} exact>
|
<Route key={path} path={`/account/${path}`.replace('//', '/')} exact>
|
||||||
<Component />
|
<Component />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
|
@ -40,7 +40,7 @@ export const NavigationLinks = () => {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Blueprint routes */}
|
{/* Blueprint routes */}
|
||||||
{blueprintRoutes.server
|
{blueprintRoutes.server.length > 0 && blueprintRoutes.server
|
||||||
.filter((route) => !!route.name)
|
.filter((route) => !!route.name)
|
||||||
.map((route) =>
|
.map((route) =>
|
||||||
route.permission ? (
|
route.permission ? (
|
||||||
|
@ -85,7 +85,7 @@ export const NavigationRouter = () => {
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* Blueprint routes */}
|
{/* Blueprint routes */}
|
||||||
{blueprintRoutes.server.map(({ path, permission, component: Component }) => (
|
{blueprintRoutes.server.length > 0 && blueprintRoutes.server.map(({ path, permission, component: Component }) => (
|
||||||
<PermissionRoute key={path} permission={permission} path={to(path)} exact>
|
<PermissionRoute key={path} permission={permission} path={to(path)} exact>
|
||||||
<Spinner.Suspense>
|
<Spinner.Suspense>
|
||||||
<Component />
|
<Component />
|
||||||
|
|
|
@ -2,9 +2,19 @@ import React from 'react';
|
||||||
|
|
||||||
/* blueprint/import */
|
/* blueprint/import */
|
||||||
|
|
||||||
interface ExtendedRouteDefinition { path: string; name: string | undefined; component: React.ComponentType; exact?: boolean; }
|
interface RouteDefinition {
|
||||||
interface ExtendedServerRouteDefinition extends ExtendedRouteDefinition { permission: string | string[] | null; }
|
path: string;
|
||||||
interface ExtendedRoutes { account: ExtendedRouteDefinition[]; server: ExtendedServerRouteDefinition[]; }
|
name: string | undefined;
|
||||||
|
component: React.ComponentType;
|
||||||
|
exact?: boolean;
|
||||||
|
}
|
||||||
|
interface ServerRouteDefinition extends RouteDefinition {
|
||||||
|
permission: string | string[] | null;
|
||||||
|
}
|
||||||
|
interface Routes {
|
||||||
|
account: RouteDefinition[];
|
||||||
|
server: ServerRouteDefinition[];
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
account: [
|
account: [
|
||||||
|
@ -13,4 +23,4 @@ export default {
|
||||||
server: [
|
server: [
|
||||||
/* routes/server */
|
/* routes/server */
|
||||||
],
|
],
|
||||||
} as ExtendedRoutes;
|
} as Routes;
|
Loading…
Reference in a new issue