diff --git a/src/store/url.ts b/src/store/url.ts index a5c9180c..2dd80ed9 100644 --- a/src/store/url.ts +++ b/src/store/url.ts @@ -24,12 +24,17 @@ type CurrentApplicantIdStore = { updateCurrentApplicantId: (id: number) => void; }; -export const useCurrentApplicantIdStore = create()( - (set) => ({ - currentApplicantId: null, - updateCurrentApplicantId: (newId: number) => - set(() => ({ currentApplicantId: newId })), - }), +export const useCurrentApplicantIdStore = create( + persist( + (set) => ({ + currentApplicantId: null, + updateCurrentApplicantId: (newId: number) => + set(() => ({ currentApplicantId: newId })), + }), + { + name: 'currentApplicantIdStore', + }, + ), ); type CurrentDocumentIdStore = { @@ -37,12 +42,17 @@ type CurrentDocumentIdStore = { updateCurrentDocumentId: (id: number) => void; }; -export const useCurrentDocumentIdStore = create()( - (set) => ({ - currentDocumentId: null, - updateCurrentDocumentId: (newId: number) => - set(() => ({ currentDocumentId: newId })), - }), +export const useCurrentDocumentIdStore = create( + persist( + (set) => ({ + currentDocumentId: null, + updateCurrentDocumentId: (newId: number) => + set(() => ({ currentDocumentId: newId })), + }), + { + name: 'currentDocumentIdStore', + }, + ), ); type CurrentPostIdStoreEmployee = { @@ -50,9 +60,15 @@ type CurrentPostIdStoreEmployee = { updateCurrentPostId: (id: number) => void; }; -export const useCurrentPostIdEmployeeStore = - create()((set) => ({ - currentPostId: null, - updateCurrentPostId: (newId: number) => - set(() => ({ currentPostId: newId })), - })); +export const useCurrentPostIdEmployeeStore = create( + persist( + (set) => ({ + currentPostId: null, + updateCurrentPostId: (newId: number) => + set(() => ({ currentPostId: newId })), + }), + { + name: 'useCurrentPostIdEmployeeStore', + }, + ), +); diff --git a/src/utils/clearAllStore.ts b/src/utils/clearAllStore.ts index 61e45f50..54ebe480 100644 --- a/src/utils/clearAllStore.ts +++ b/src/utils/clearAllStore.ts @@ -1,6 +1,11 @@ import { usePostSearchStore } from '@/store/postSearch'; import { useEmailTryCountStore } from '@/store/signup'; -import { useCurrentApplicantIdStore, useCurrentPostIdStore } from '@/store/url'; +import { + useCurrentApplicantIdStore, + useCurrentDocumentIdStore, + useCurrentPostIdEmployeeStore, + useCurrentPostIdStore, +} from '@/store/url'; import { useUserStore } from '@/store/user'; // store 전역 변수 초기화 @@ -10,4 +15,6 @@ export const clearAllStore = () => { useEmailTryCountStore.persist.clearStorage(); useCurrentPostIdStore.persist.clearStorage(); useCurrentApplicantIdStore.persist.clearStorage(); + useCurrentDocumentIdStore.persist.clearStorage(); + useCurrentPostIdEmployeeStore.persist.clearStorage(); };