feat: add settings and access dashboard slice
This commit is contained in:
1 parent
dcf2a1200c
commit
79de6aa2a1
11 files changed
+1066
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { SettingsPage, type SettingsSection } from './settings-page.js';
|
||||
|
||||
const validSections: readonly SettingsSection[] = ['monitoring', 'rate-limits', 'behaviour', 'access'];
|
||||
|
||||
function parseSection(value: string | null): SettingsSection {
|
||||
return validSections.find((section) => section === value) ?? 'monitoring';
|
||||
}
|
||||
|
||||
export function SettingsRoute() {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const section = parseSection(searchParams.get('section'));
|
||||
|
||||
function selectSection(nextSection: SettingsSection) {
|
||||
setSearchParams({ section: nextSection }, { replace: true });
|
||||
}
|
||||
|
||||
return <SettingsPage onSectionChange={selectSection} section={section} />;
|
||||
}
|
||||
Reference in new issue
Block a user