This commit is contained in:
cracklesparkle
2025-01-30 12:36:39 +09:00
parent e6b3dc05d3
commit 0788a401ca
43 changed files with 3710 additions and 1724 deletions

43
client/src/store/app.ts Normal file
View File

@ -0,0 +1,43 @@
import { create } from 'zustand';
export type Mode = 'edit' | 'view'
export interface AppState {
mapTab: Record<string, {
year: number | null,
region: number | null,
district: number | null
}>,
currentTab: string | null;
}
export const useAppStore = create<AppState>(() => ({
currentTab: null,
mapTab: {}
}))
const getCurrentTab = () => useAppStore.getState().currentTab
const setCurrentTab = (id: string | null) => useAppStore.setState(() => ({ currentTab: id }))
const setMapTabYear = (id: string, year: number | null) =>
useAppStore.setState((state) => {
return {
mapTab: {
...state.mapTab,
[id]: { ...state.mapTab[id], year: year }
}
}
})
const deleteMapTab = (id: string) =>
useAppStore.setState((state) => {
const { [id]: _, ...remainingTabs } = state.mapTab;
return { mapTab: remainingTabs };
})
export {
deleteMapTab,
getCurrentTab,
setCurrentTab,
setMapTabYear
}