diff --git a/frontend/src/pages/AdminPage.tsx b/frontend/src/pages/AdminPage.tsx index c25c3d622..b1ffe2b87 100644 --- a/frontend/src/pages/AdminPage.tsx +++ b/frontend/src/pages/AdminPage.tsx @@ -8,16 +8,16 @@ import useToast from '@/hooks/useToast'; import { boxShadowSpread, flexRow, title2, title3 } from '@/styles/common'; const AdminPage = () => { - const { data: user } = useUserQuery(); + const { data: user, isFetched } = useUserQuery(); const { showToast } = useToast(); const navigate = useNavigate(); useEffect(() => { - if (user?.userType !== 'ADMIN') { + if (isFetched && user?.userType !== 'ADMIN') { showToast({ message: '해당 페이지 접근 권한이 없습니다.', type: 'error' }); navigate(ROUTE_PATH.root); } - }, []); + }, [isFetched]); return ( diff --git a/frontend/src/store/roomInfoNonValidatedStore.ts b/frontend/src/store/roomInfoNonValidatedStore.ts index f07a2f078..7c4eee5fc 100644 --- a/frontend/src/store/roomInfoNonValidatedStore.ts +++ b/frontend/src/store/roomInfoNonValidatedStore.ts @@ -1,5 +1,5 @@ import { createStore } from 'zustand'; -import { persist } from 'zustand/middleware'; +import { createJSONStorage, persist } from 'zustand/middleware'; import { DEFAULT_POSITION } from '@/constants/map'; import { Position } from '@/types/address'; @@ -33,7 +33,7 @@ const roomInfoNonValidatedStore = createStore()( }), { name: 'roomInfo-nonvalidated', - getStorage: () => sessionStorage, + storage: createJSONStorage(() => sessionStorage), partialize: store => { const { actions: _, ...state } = store; return { ...state }; diff --git a/frontend/src/store/roomInfoStore.ts b/frontend/src/store/roomInfoStore.ts index 5584a6903..c09d15c36 100644 --- a/frontend/src/store/roomInfoStore.ts +++ b/frontend/src/store/roomInfoStore.ts @@ -1,5 +1,5 @@ import { createStore } from 'zustand'; -import { persist } from 'zustand/middleware'; +import { createJSONStorage, persist } from 'zustand/middleware'; import { roomFloorLevels, roomOccupancyPeriods } from '@/constants/roomInfo'; import { parseRoomInfo } from '@/hooks/useRoomInfoValidated'; @@ -99,7 +99,7 @@ export const roomInfoStore = createStore sessionStorage, + storage: createJSONStorage(() => sessionStorage), partialize: state => { const { actions: _, ...roomInfo } = state; return { ...roomInfo }; diff --git a/frontend/src/store/useChecklistStore.ts b/frontend/src/store/useChecklistStore.ts index c00d1a35c..416249e0c 100644 --- a/frontend/src/store/useChecklistStore.ts +++ b/frontend/src/store/useChecklistStore.ts @@ -1,5 +1,5 @@ import { create } from 'zustand'; -import { persist } from 'zustand/middleware'; +import { createJSONStorage, persist } from 'zustand/middleware'; import { AnswerType } from '@/types/answer'; import { Category } from '@/types/category'; @@ -119,7 +119,7 @@ const useChecklistStore = create()( }), { name: 'checklist-answer', - getStorage: () => sessionStorage, + storage: createJSONStorage(() => sessionStorage), partialize: ({ checklistCategoryQnA, categories }) => ({ checklistCategoryQnA, categories, diff --git a/frontend/src/store/useSelectedOptionStore.ts b/frontend/src/store/useSelectedOptionStore.ts index fd45b735d..8d264809b 100644 --- a/frontend/src/store/useSelectedOptionStore.ts +++ b/frontend/src/store/useSelectedOptionStore.ts @@ -1,5 +1,5 @@ import { create } from 'zustand'; -import { persist } from 'zustand/middleware'; +import { createJSONStorage, persist } from 'zustand/middleware'; import { DEFAULT_OPTIONS, OPTION_COUNT, OPTIONS } from '@/constants/options'; @@ -66,7 +66,7 @@ const useSelectedOptionStore = create() }), { name: 'checklist-answer-option', - getStorage: () => sessionStorage, + storage: createJSONStorage(() => sessionStorage), partialize: state => ({ selectedOptions: state.selectedOptions, // actions는 저장하지 않음