diff --git a/src/dashboard/routes.ts b/src/dashboard/routes.ts new file mode 100644 index 0000000000..e3df4a471b --- /dev/null +++ b/src/dashboard/routes.ts @@ -0,0 +1,6 @@ +import type { RouteDef } from "../route-config"; +import { DashboardRoute } from "./routes/Dashboard"; + +const routes: RouteDef[] = [DashboardRoute]; + +export default routes; diff --git a/src/dashboard/routes/Dashboard.ts b/src/dashboard/routes/Dashboard.ts new file mode 100644 index 0000000000..9a2564c3c1 --- /dev/null +++ b/src/dashboard/routes/Dashboard.ts @@ -0,0 +1,19 @@ +import type { LocationDescriptorObject } from "history"; +import { generatePath } from "react-router-dom"; +import type { RouteDef } from "../../route-config"; +import { DashboardSection } from "../Dashboard"; + +export type DashboardParams = { realm?: string }; + +export const DashboardRoute: RouteDef = { + path: "/:realm?", + component: DashboardSection, + breadcrumb: (t) => t("common:home"), + access: "anyone", +}; + +export const toDashboard = ( + params: DashboardParams +): LocationDescriptorObject => ({ + pathname: generatePath(DashboardRoute.path, params), +}); diff --git a/src/route-config.ts b/src/route-config.ts index 5b94285521..50e35b46eb 100644 --- a/src/route-config.ts +++ b/src/route-config.ts @@ -5,7 +5,7 @@ import type { MatchOptions } from "use-react-router-breadcrumbs"; import authenticationRoutes from "./authentication/routes"; import clientScopesRoutes from "./client-scopes/routes"; import clientRoutes from "./clients/routes"; -import { DashboardSection } from "./dashboard/Dashboard"; +import dashboardRoutes from "./dashboard/routes"; import eventRoutes from "./events/routes"; import { GroupsSection } from "./groups/GroupsSection"; import { SearchGroups } from "./groups/SearchGroups"; @@ -38,12 +38,7 @@ export const routes: RouteDef[] = [ ...sessionRoutes, ...userFederationRoutes, ...userRoutes, - { - path: "/:realm/", - component: DashboardSection, - breadcrumb: (t) => t("common:home"), - access: "anyone", - }, + ...dashboardRoutes, { path: "/:realm/groups/search", component: SearchGroups, @@ -58,12 +53,6 @@ export const routes: RouteDef[] = [ exact: false, }, }, - { - path: "/", - component: DashboardSection, - breadcrumb: (t) => t("common:home"), - access: "anyone", - }, { path: "*", component: PageNotFoundSection,