diff --git a/src/store/store.ts b/src/store/store.ts index 2409a76..18aabdc 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -1,5 +1,7 @@ import { create } from "zustand"; +import { persist } from "zustand/middleware"; + type UserProps = { name: string; department: string; @@ -10,9 +12,17 @@ type UserAction = { setDepartment: (department: UserProps["department"]) => void; }; -export const useUserInfo = create()((set) => ({ - name: "", - department: "", - setName: (name) => set(() => ({ name: name })), - setDepartment: (department) => set(() => ({ department: department })), -})); +export const useUserInfo = create()( + persist( + (set) => ({ + name: "", + department: "", + setName: (name) => set(() => ({ name: name })), + setDepartment: (department) => set(() => ({ department: department })), + }), + { + name: "user-storage", + getStorage: () => localStorage, + }, + ), +);