Skip to content

Commit

Permalink
#553 - feat: add sidebar to BaseSettingsView
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jan 10, 2025
1 parent 8b455b6 commit 0e89173
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frontend/src/pages/settings/abstract/BaseSettingsView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DataGridProps, ListTemplate, ToolbarItem } from "@maykin-ui/admin-ui";
import React from "react";
import { useMatches, useNavigate } from "react-router-dom";

export type BaseSettingsPageProps<T extends object> = React.PropsWithChildren<{
dataGridProps: DataGridProps<T>;
Expand All @@ -14,9 +15,21 @@ export function BaseSettingsView<T extends object>({
dataGridProps,
secondaryNavigationItems,
}: BaseSettingsPageProps<T>) {
const navigate = useNavigate();
const currentMatch = [...useMatches()].pop(); // Explicit clone.
const currentPathName = currentMatch?.pathname;

return (
<ListTemplate<T>
secondaryNavigationItems={secondaryNavigationItems}
sidebarItems={[
{
children: "Verkorte procedure",
align: "start",
onClick: () => navigate("/settings/short-procedure"),
active: currentPathName === "/settings/short-procedure",
},
]}
dataGridProps={dataGridProps}
>
{children}
Expand Down

0 comments on commit 0e89173

Please sign in to comment.