import create from 'zustand' ; import { InititalState , Filters } from './types/interfaces' ; import { User , Keycapset } from './types/types' ; interface Actions { setUser ( user ) : void ; setUserWants ( userWants ) : void ; setFilters ( filters ) : void ; setDarkMode ( darkmode ) : void ; } export const emptyFilters = { availability : 'none' , name : '' , brand : [ ] , type : [ ] , material : [ ] , } ; export const INITITAL_STATE = { filters : emptyFilters , keycapsets : [ ] , searchQuery : '' , allKeycapsetsCount : 0 , userWants : [ ] , isLoggedIn : false , user : null , isDarkMode : null , } ; const useStore = create < InititalState & Actions > ( ( set ) => ( { ... INITITAL_STATE , setUser : ( user ) => set ( { user , isLoggedIn : true } ) , setUserWants : ( userWants ) => set ( { userWants } ) , setFilters : ( filters ) => set ( { filters } ) , setDarkMode : ( isDarkMode ) => set ( { isDarkMode } ) , } ) ) ; export default useStore ;