mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
refactor(store): rename useSettingNavStore to useSettingsStore and update state structure
This commit is contained in:
parent
a7a50231d2
commit
efa16c8b77
@ -1,22 +0,0 @@
|
|||||||
import { create } from "zustand";
|
|
||||||
import { persist } from "zustand/middleware";
|
|
||||||
|
|
||||||
interface SettingNavState {
|
|
||||||
activeNav: string;
|
|
||||||
setActiveNav: (nav: string) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSettingNavStore = create<SettingNavState>()(
|
|
||||||
persist(
|
|
||||||
(set) => ({
|
|
||||||
activeNav: "Appearance",
|
|
||||||
setActiveNav: (nav) => set({ activeNav: nav }),
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
name: "setting-nav-active",
|
|
||||||
partialize: (state) => ({
|
|
||||||
activeNav: state.activeNav,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
27
src/store/useSettingsStore.ts
Normal file
27
src/store/useSettingsStore.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
import { persist } from "zustand/middleware";
|
||||||
|
|
||||||
|
interface SettingsState {
|
||||||
|
activeSetting: string;
|
||||||
|
isDialogOpen: boolean;
|
||||||
|
setActiveSetting: (setting: string) => void;
|
||||||
|
setDialogOpen: (open: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useSettingsStore = create<SettingsState>()(
|
||||||
|
persist(
|
||||||
|
(set) => ({
|
||||||
|
activeSetting: "Appearance",
|
||||||
|
isDialogOpen: false,
|
||||||
|
setActiveSetting: (setting) => set({ activeSetting: setting }),
|
||||||
|
setDialogOpen: (open) => set({ isDialogOpen: open }),
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
name: "settings-state",
|
||||||
|
partialize: (state) => ({
|
||||||
|
activeNav: state.activeSetting,
|
||||||
|
isDialogOpen: state.isDialogOpen,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user