init
This commit is contained in:
22
stores/localeStore.ts
Normal file
22
stores/localeStore.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import Cookies from 'js-cookie';
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface LocaleState {
|
||||
showLanguageAlert: boolean
|
||||
setShowLanguageAlert: (show: boolean) => void
|
||||
dismissLanguageAlert: () => void
|
||||
getLangAlertDismissed: () => boolean
|
||||
}
|
||||
|
||||
export const useLocaleStore = create<LocaleState>((set) => ({
|
||||
showLanguageAlert: false,
|
||||
setShowLanguageAlert: (show) => set({ showLanguageAlert: show }),
|
||||
dismissLanguageAlert: () => {
|
||||
// cookie expires 30 days
|
||||
Cookies.set("langAlertDismissed", "true", { expires: 30 });
|
||||
set({ showLanguageAlert: false });
|
||||
},
|
||||
getLangAlertDismissed: () => {
|
||||
return Cookies.get("langAlertDismissed") === "true";
|
||||
},
|
||||
}))
|
||||
15
stores/sectionStore.ts
Normal file
15
stores/sectionStore.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
export type SectionItem = { id: string; name: string };
|
||||
|
||||
type SectionStore = {
|
||||
sections: SectionItem[];
|
||||
setSections: (items: SectionItem[]) => void;
|
||||
clear: () => void;
|
||||
};
|
||||
|
||||
export const useSectionStore = create<SectionStore>((set) => ({
|
||||
sections: [],
|
||||
setSections: (items) => set({ sections: items }),
|
||||
clear: () => set({ sections: [] }),
|
||||
}));
|
||||
Reference in New Issue
Block a user