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