feat: url navigation for settings (#821)

This commit is contained in:
Carlos Valente
2024-03-18 20:36:02 +01:00
committed by GitHub
parent 4b21745fc7
commit dfade25a7c
11 changed files with 147 additions and 61 deletions
@@ -19,7 +19,7 @@ export const settingPanels: Readonly<SettingsOption[]> = [
secondary: [
{ id: 'general__manage', label: 'Manage Ontime settings' },
{ id: 'general__view', label: 'View settings' },
{ id: 'general__urlPresets', label: 'URL presets' },
{ id: 'general__urlpresets', label: 'URL presets' },
],
},
{
@@ -54,11 +54,11 @@ export const settingPanels: Readonly<SettingsOption[]> = [
] as const;
export type SettingsOptionId = (typeof settingPanels)[number]['id'];
const firstPanel = settingPanels[0].id;
export interface PanelBaseProps {
location?: string;
}
type SettingsStore = {
showSettings: SettingsOptionId | null;
setShowSettings: (panelId?: SettingsOptionId | null) => void;
unsavedChanges: Set<SettingsOptionId>;
hasUnsavedChanges: (panelId: SettingsOptionId) => boolean;
addUnsavedChanges: (panelId: SettingsOptionId) => void;
@@ -66,16 +66,6 @@ type SettingsStore = {
};
export const useSettingsStore = create<SettingsStore>((set, get) => ({
showSettings: null,
setShowSettings: (panelId?: SettingsOptionId | null) => {
const newPanel = panelId === undefined ? firstPanel : panelId;
set((state) => {
return {
...state,
showSettings: newPanel,
};
});
},
unsavedChanges: new Set(),
hasUnsavedChanges: (panelId: SettingsOptionId) => get().unsavedChanges.has(panelId),
addUnsavedChanges: (panelId: SettingsOptionId) =>