This commit is contained in:
@@ -1,19 +1,30 @@
|
||||
import { AvatarHakushiType, EnemyHakushiType } from '@/types';
|
||||
import { CharacterBasic, MonsterBasic } from '@/types';
|
||||
import { create } from 'zustand'
|
||||
|
||||
|
||||
interface AvatarDataState {
|
||||
listAvatar: AvatarHakushiType[];
|
||||
listEnemy: EnemyHakushiType[];
|
||||
setListAvatar: (list: AvatarHakushiType[]) => void;
|
||||
setListEnemy: (list: EnemyHakushiType[]) => void;
|
||||
listAvatar: CharacterBasic[];
|
||||
mapAvatar: Record<string, CharacterBasic>;
|
||||
listEnemy: MonsterBasic[];
|
||||
mapEnemy: Record<string, MonsterBasic>;
|
||||
setListAvatar: (list: CharacterBasic[]) => void;
|
||||
setMapAvatar: (data: Record<string, CharacterBasic>) => void;
|
||||
setListEnemy: (list: MonsterBasic[]) => void;
|
||||
setMapEnemy: (data: Record<string, MonsterBasic>) => void;
|
||||
|
||||
|
||||
}
|
||||
|
||||
const useAvatarDataStore = create<AvatarDataState>((set) => ({
|
||||
listAvatar: [],
|
||||
listEnemy: [],
|
||||
setListAvatar: (list: AvatarHakushiType[]) => set({ listAvatar: list }),
|
||||
setListEnemy: (list: EnemyHakushiType[]) => set({ listEnemy: list }),
|
||||
mapAvatar: {},
|
||||
mapEnemy: {},
|
||||
setListAvatar: (list: CharacterBasic[]) => set({ listAvatar: list }),
|
||||
setMapAvatar: (data: Record<string, CharacterBasic>) => set({ mapAvatar: data }),
|
||||
setListEnemy: (list: MonsterBasic[]) => set({ listEnemy: list }),
|
||||
setMapEnemy: (data: Record<string, MonsterBasic>) => set({ mapEnemy: data })
|
||||
|
||||
}));
|
||||
|
||||
export default useAvatarDataStore;
|
||||
@@ -1,15 +1,25 @@
|
||||
import { create } from 'zustand'
|
||||
import { createJSONStorage, persist } from 'zustand/middleware';
|
||||
|
||||
|
||||
interface LocaleState {
|
||||
locale: string;
|
||||
theme: string
|
||||
setTheme: (newTheme: string) => void;
|
||||
setLocale: (newLocale: string) => void;
|
||||
}
|
||||
|
||||
const useLocaleStore = create<LocaleState>((set) => ({
|
||||
locale: "en",
|
||||
setLocale: (newLocale: string) => set({ locale: newLocale }),
|
||||
|
||||
}));
|
||||
const useLocaleStore = create<LocaleState>()(persist(
|
||||
(set) => ({
|
||||
locale: "en",
|
||||
theme: "night",
|
||||
setTheme: (newTheme: string) => set({ theme: newTheme }),
|
||||
setLocale: (newLocale: string) => set({ locale: newLocale }),
|
||||
}),
|
||||
{
|
||||
name: 'locale-storage',
|
||||
storage: createJSONStorage(() => localStorage),
|
||||
}
|
||||
));
|
||||
|
||||
export default useLocaleStore;
|
||||
Reference in New Issue
Block a user