From b70ddd83814427fe9c05e50b5ef4070bef424efb Mon Sep 17 00:00:00 2001 From: chaeyeon LEE <98521882+colorkite10@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:42:06 +0900 Subject: [PATCH] =?UTF-8?q?SKRF-462=20fix:=20=EB=B9=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=8B=9C=20profile=20=EC=9A=94=EC=B2=AD=20x=20(#22?= =?UTF-8?q?3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 비로그인 시 profile 요청 x * fix: 비로그인 시 clubs 요청 x --- src/hooks/query/club/useClubs.tsx | 3 +++ src/hooks/query/user/useMyProfile.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/hooks/query/club/useClubs.tsx b/src/hooks/query/club/useClubs.tsx index a4cbafb4..c55f85b7 100644 --- a/src/hooks/query/club/useClubs.tsx +++ b/src/hooks/query/club/useClubs.tsx @@ -1,4 +1,5 @@ import getMyClubs from '@/apis/users/getMyClub'; +import { getStorage } from '@/utils/localStorage'; import { useQuery } from '@tanstack/react-query'; @@ -7,10 +8,12 @@ export const QUERY_KEY = { }; const useClubs = () => { + const token = getStorage('token'); const { data, isLoading } = useQuery({ queryFn: () => getMyClubs(), queryKey: [QUERY_KEY.MY_CLUB], staleTime: 1000 * 60, + enabled: !!token, }); return { clubs: data, isLoading }; diff --git a/src/hooks/query/user/useMyProfile.ts b/src/hooks/query/user/useMyProfile.ts index 5fd37554..13655f27 100644 --- a/src/hooks/query/user/useMyProfile.ts +++ b/src/hooks/query/user/useMyProfile.ts @@ -16,6 +16,7 @@ export const QUERY_KEY = { }; const useMyProfile = ({ setValue }: useMyProfile = {}) => { + const token = getStorage('token'); const { data } = useQuery({ queryKey: [QUERY_KEY.MY_PROFILE, QUERY_KEY.ID], queryFn: () => getMyProfileInfo(), @@ -25,6 +26,7 @@ const useMyProfile = ({ setValue }: useMyProfile = {}) => { setValue('number', phoneNumber); } }, + enabled: !!token, }); return { data };