From d6666d7faa4d30ab39e2a116e4ba5c23c026bc55 Mon Sep 17 00:00:00 2001 From: se0jinYoon Date: Tue, 19 Nov 2024 00:03:57 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=98=A8=EB=B3=B4=EB=94=A9=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20=ED=9B=84=20SeniorId=20=EB=B0=9B=EC=95=84=EC=99=80?= =?UTF-8?q?=EC=84=9C=20=ED=94=84=EB=A1=9C=ED=95=84=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=EC=8B=9C=20=EC=98=A8=EB=B3=B4=EB=94=A9=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EB=B6=88=EB=9F=AC=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/onboarding/hooks/useJoinQuery.ts | 3 ++- src/pages/seniorProfile/SeniorProfilePage.tsx | 9 +++++---- src/pages/seniorProfile/components/preView/index.tsx | 6 +----- src/utils/storage.ts | 9 +++++++++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/pages/onboarding/hooks/useJoinQuery.ts b/src/pages/onboarding/hooks/useJoinQuery.ts index 09b95c63..aeef96e7 100644 --- a/src/pages/onboarding/hooks/useJoinQuery.ts +++ b/src/pages/onboarding/hooks/useJoinQuery.ts @@ -1,13 +1,14 @@ import { useMutation } from '@tanstack/react-query'; import { joinAxios } from '../apis/joinAxios'; import { JoinPropType } from '../type'; -import { setRole } from '@utils/storage'; +import { setRole, setSeniorId } from '@utils/storage'; const useJoinQuery = () => { const mutation = useMutation({ mutationFn: (requestBody: JoinPropType) => joinAxios(requestBody), onSuccess: (data) => { setRole(data.data.data.role); + setSeniorId(data.data.data.seniorId + ''); }, onError: (error) => { console.log('πŸ”΄ join patch Error: ', error); diff --git a/src/pages/seniorProfile/SeniorProfilePage.tsx b/src/pages/seniorProfile/SeniorProfilePage.tsx index ae855118..77a4baa2 100644 --- a/src/pages/seniorProfile/SeniorProfilePage.tsx +++ b/src/pages/seniorProfile/SeniorProfilePage.tsx @@ -15,7 +15,7 @@ import { Header } from '../../components/commons/Header'; import ProgressBar from '../../components/commons/ProgressBar'; import theme from '../../styles/theme'; import { useNavigate } from 'react-router-dom'; -import { getSeniorNickname } from '@utils/storage'; +import { getSeniorId, getSeniorNickname } from '@utils/storage'; const SeniorProfilePage = () => { const [step, setStep] = useState(0); @@ -23,11 +23,12 @@ const SeniorProfilePage = () => { const navigate = useNavigate(); const nickname = getSeniorNickname(); + const seniorId = getSeniorId() ?? ''; const userName = step >= 2 && step <= 4 ? nickname : ''; useEffect(() => { - if (!nickname) navigate('/'); - }, [nickname]); + if (seniorId === '' || !nickname) navigate('/'); + }, [nickname, seniorId]); const getComponent = () => { switch (step) { @@ -44,7 +45,7 @@ const SeniorProfilePage = () => { case 5: return ; case 6: - return ; + return ; case 7: return ; default: diff --git a/src/pages/seniorProfile/components/preView/index.tsx b/src/pages/seniorProfile/components/preView/index.tsx index 2ffb6cbb..02ee8976 100644 --- a/src/pages/seniorProfile/components/preView/index.tsx +++ b/src/pages/seniorProfile/components/preView/index.tsx @@ -27,11 +27,7 @@ interface preViewPropType { const PreView = ({ seniorId, profile, setStep, variant = 'default' }: preViewPropType) => { // μ„ λ°° μΉ΄λ“œ 정보 쑰회 (μ˜¨λ³΄λ”© 정보) - const { - data: cardData, - error: cardDataError, - isLoading: isCardDataLoading, - } = useSeniorCardQuery(seniorId, variant === 'secondary'); + const { data: cardData, error: cardDataError, isLoading: isCardDataLoading } = useSeniorCardQuery(seniorId, true); // μ„ λ°° 상세 ν”„λ‘œν•„ 쑰회 (ν”„λ‘œν•„ 정보) const { data: profileData, diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 276a9b7e..49b7ca65 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -18,6 +18,7 @@ export const clearStorage = () => { localStorage.removeItem('seonyakToken'); localStorage.removeItem('seonyakRole'); localStorage.removeItem('seniorNickname'); + localStorage.removeItem('seniorId'); }; // μ˜¨λ³΄λ”© μ™„λ£Œ ν›„ ν”„λ‘œν•„ 등둝 μ•ˆ ν•˜κ³  μ΄νƒˆν•œ μ„ λ°° 정보 μ €μž₯ @@ -28,3 +29,11 @@ export const setSeniorNickname = (nickname: string) => { export const getSeniorNickname = () => { return localStorage.getItem('seniorNickname'); }; + +export const setSeniorId = (id: string) => { + localStorage.setItem('seniorId', id); +} + +export const getSeniorId = () => { + return localStorage.getItem('seniorId'); +} \ No newline at end of file