From d1a593467a40df2ea48c7079ea1bbe715830163c Mon Sep 17 00:00:00 2001 From: SeieunYoo Date: Fri, 9 Aug 2024 16:41:07 +0900 Subject: [PATCH 1/8] =?UTF-8?q?fix:=20=EB=94=94=EC=8A=A4=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EA=B4=80=EB=A0=A8=20qa=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/discordConnect/DiscordName.tsx | 8 ++--- .../discordConnect/DiscordNickName.tsx | 8 ++--- src/components/discordConnect/JoinServer.tsx | 30 +++++++++++++++++-- src/hooks/mutation/usePostDiscordName.ts | 4 +-- src/hooks/mutation/usePostDiscordNickname.ts | 4 +-- src/hooks/query/useGetDiscordJoined.ts | 10 +++++-- 6 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/components/discordConnect/DiscordName.tsx b/src/components/discordConnect/DiscordName.tsx index 9c64aa8..de483ff 100644 --- a/src/components/discordConnect/DiscordName.tsx +++ b/src/components/discordConnect/DiscordName.tsx @@ -15,9 +15,7 @@ export const DiscordName = ({ onNext }: { onNext: () => void }) => { const { getValues, control, trigger, setError } = useFormContext(); - const { checkDuplicate, data, isSuccess } = usePostDiscordName( - getValues('discordUsername') - ); + const { checkDuplicate, data, isSuccess } = usePostDiscordName(); useEffect(() => { if (isSuccess) { @@ -36,14 +34,14 @@ export const DiscordName = ({ onNext }: { onNext: () => void }) => { const handleNextClick = useCallback(async () => { const isValid = await trigger('discordUsername'); if (isValid) { - checkDuplicate(); + checkDuplicate(getValues('discordUsername')); } else { setError('discordUsername', { type: 'manual', message: '하단 규정에 맞춰 작성해주세요.' }); } - }, [checkDuplicate, setError, trigger]); + }, [checkDuplicate, getValues, setError, trigger]); return ( <> diff --git a/src/components/discordConnect/DiscordNickName.tsx b/src/components/discordConnect/DiscordNickName.tsx index 1b47310..f8a56f0 100644 --- a/src/components/discordConnect/DiscordNickName.tsx +++ b/src/components/discordConnect/DiscordNickName.tsx @@ -12,9 +12,7 @@ import Divider from 'wowds-ui/Divider'; export const DiscordNickName = ({ onNext }: { onNext: () => void }) => { const { getValues, control, setError, clearErrors, trigger } = useFormContext(); - const { checkDuplicate, data, isSuccess } = usePostDiscordNickname( - getValues('discordNickname') - ); + const { checkDuplicate, data, isSuccess } = usePostDiscordNickname(); useEffect(() => { if (isSuccess) { @@ -33,14 +31,14 @@ export const DiscordNickName = ({ onNext }: { onNext: () => void }) => { const handleNextClick = useCallback(async () => { const isValid = await trigger('discordNickname'); if (isValid) { - checkDuplicate(); + checkDuplicate(getValues('discordUsername')); } else { setError('discordNickname', { type: 'manual', message: '하단 규정에 맞춰 작성해주세요.' }); } - }, [checkDuplicate, setError, trigger]); + }, [checkDuplicate, getValues, setError, trigger]); return ( <> diff --git a/src/components/discordConnect/JoinServer.tsx b/src/components/discordConnect/JoinServer.tsx index bf11183..ab14f05 100644 --- a/src/components/discordConnect/JoinServer.tsx +++ b/src/components/discordConnect/JoinServer.tsx @@ -7,10 +7,32 @@ import { useFormContext } from 'react-hook-form'; import useGetDiscordJoined from '@/hooks/query/useGetDiscordJoined'; import { DiscordFormValues } from '@/types/discord'; import RoutePath from '@/routes/routePath'; +import { useState, useEffect } from 'react'; + +const FETCH_INTERVAL = 5000; export const JoinServer = ({ onNext }: { onNext: () => void }) => { const { getValues } = useFormContext(); - const { data } = useGetDiscordJoined(getValues('discordUsername')); + const [isEnabled, setIsEnabled] = useState(false); + + //NOTE: 처음 렌더링 되었을 때에 바로 fetch 하지 않고 5초 기다린 후에 fetch 합니다. + useEffect(() => { + const timer = setTimeout(() => { + setIsEnabled(true); + }, FETCH_INTERVAL); + + return () => clearTimeout(timer); + }, []); + + const { data } = useGetDiscordJoined(getValues('discordUsername'), isEnabled); + + //NOTE : 합류여부가 true 일 경우에는 더 이상 fetch 하지 않습니다. + useEffect(() => { + if (data?.isJoined) { + setIsEnabled(false); + } + }, [data]); + return ( <> @@ -38,7 +60,11 @@ export const JoinServer = ({ onNext }: { onNext: () => void }) => { }} disabled={!data?.isJoined} style={{ maxWidth: '100%' }}> - 합류가 확인되면 넘어갈 수 있어요. + {!isEnabled + ? '잠시만 기다려주세요.' + : data?.isJoined + ? '합류가 확인되었어요.' + : '합류가 확인되지 않았어요.'} discordApi.GET_DISCORD_NAME(userName) + mutationFn: (userName: string) => discordApi.GET_DISCORD_NAME(userName) }); return { checkDuplicate, ...rest }; } diff --git a/src/hooks/mutation/usePostDiscordNickname.ts b/src/hooks/mutation/usePostDiscordNickname.ts index c420758..911545b 100644 --- a/src/hooks/mutation/usePostDiscordNickname.ts +++ b/src/hooks/mutation/usePostDiscordNickname.ts @@ -1,9 +1,9 @@ import discordApi from '@/apis/discord/discordApi'; import { useMutation } from '@tanstack/react-query'; -export function usePostDiscordNickname(nickname: string) { +export function usePostDiscordNickname() { const { mutate: checkDuplicate, ...rest } = useMutation({ - mutationFn: () => discordApi.GET_DISCORD_NICKNAME(nickname) + mutationFn: (nickname: string) => discordApi.GET_DISCORD_NICKNAME(nickname) }); return { checkDuplicate, ...rest }; } diff --git a/src/hooks/query/useGetDiscordJoined.ts b/src/hooks/query/useGetDiscordJoined.ts index 2e19d28..db4fdd8 100644 --- a/src/hooks/query/useGetDiscordJoined.ts +++ b/src/hooks/query/useGetDiscordJoined.ts @@ -2,11 +2,17 @@ import discordApi from '@/apis/discord/discordApi'; import QueryKeys from '@/constants/queryKey'; import { useQuery } from '@tanstack/react-query'; -export default function useGetDiscordJoined(username: string) { +const FETCH_INTERVAL = 5000; +export default function useGetDiscordJoined( + username: string, + isEnabled: boolean +) { const query = useQuery({ queryKey: [QueryKeys.DiscordJoined], queryFn: () => discordApi.GET_DISCORD_JOIN(username), - refetchOnWindowFocus: true + refetchOnWindowFocus: true, + refetchInterval: FETCH_INTERVAL, + enabled: isEnabled }); return query; From b094392a653b6c815e24d6b9910242dce820a5f6 Mon Sep 17 00:00:00 2001 From: SeieunYoo Date: Fri, 9 Aug 2024 17:34:24 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat=20:=20=EC=9D=B8=EC=A6=9D=EC=9D=84=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=ED=95=9C=20=EA=B2=BD=EC=9A=B0=EC=97=90?= =?UTF-8?q?=EB=8A=94=20=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8C=85=20=ED=95=98=EB=8A=94=20=EA=B0=80?= =?UTF-8?q?=EB=93=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/guard/VerificationGuard.tsx | 57 +++++++++++++++++++ src/routes/index.tsx | 22 +++++-- 2 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 src/components/auth/guard/VerificationGuard.tsx diff --git a/src/components/auth/guard/VerificationGuard.tsx b/src/components/auth/guard/VerificationGuard.tsx new file mode 100644 index 0000000..05869a1 --- /dev/null +++ b/src/components/auth/guard/VerificationGuard.tsx @@ -0,0 +1,57 @@ +import RoutePath from '@/routes/routePath'; +import { isAuthenticated } from '@/utils/auth'; +import { toast } from 'react-toastify'; +import { useNavigate } from 'react-router-dom'; +import { PropsWithChildren, useEffect } from 'react'; +import memberApi from '@/apis/member/memberApi'; +import { useQuery } from '@tanstack/react-query'; + +type GuardType = 'StudentVerification' | 'Discord' | 'SignUp'; + +interface VerificationGuardProps extends PropsWithChildren { + guardType: GuardType; +} +/** 기본 정보, 디스코드 정보, 이메일 정보가 인증되어 있는지에 대한 가드 */ + +export default function VerificationGuard({ + guardType, + children +}: VerificationGuardProps) { + const navigate = useNavigate(); + + useEffect(() => { + if (isAuthenticated()) { + // eslint-disable-next-line react-hooks/rules-of-hooks + const { data } = useQuery({ + queryKey: ['member'], + queryFn: memberApi.GET_DASHBOARD + }); + if (!data) return; + + if ( + guardType === 'SignUp' && + data.member.associateRequirement.infoStatus === 'SATISFIED' + ) { + toast.error('기본 정보를 이미 입력했습니다.'); + navigate(RoutePath.Dashboard); + return; + } else if ( + guardType === 'Discord' && + data.member.associateRequirement.discordStatus === 'SATISFIED' + ) { + toast.error('디스코드 연동을 이미 완료했습니다.'); + navigate(RoutePath.Dashboard); + return; + } else if ( + guardType === 'StudentVerification' && + data.member.associateRequirement.univStatus === 'SATISFIED' + ) { + toast.error('재학생 인증을 이미 완료했습니다.'); + navigate(RoutePath.Dashboard); + return; + } + } + }, [guardType, navigate]); + + return children; +} diff --git a/src/routes/index.tsx b/src/routes/index.tsx index a6342f4..ef3cdd0 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -22,6 +22,7 @@ import { DicordConnect } from '@/pages/DiscordConnect'; import { DiscordGuide } from '@/pages/DiscordGuide'; import { Suspense } from 'react'; import PaymentAccessGuard from '@/components/auth/guard/PaymentAccessGuard'; +import VerificationGuard from '@/components/auth/guard/VerificationGuard'; const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouter(createBrowserRouter); @@ -58,7 +59,9 @@ const router = sentryCreateBrowserRouter([ index: true, element: ( - + + + ) } @@ -67,7 +70,16 @@ const router = sentryCreateBrowserRouter([ { path: RoutePath.Signup, element: , - children: [{ index: true, element: }] + children: [ + { + index: true, + element: ( + + + + ) + } + ] }, { path: RoutePath.Home, @@ -79,11 +91,13 @@ const router = sentryCreateBrowserRouter([ }, { path: RoutePath.Discord, - element: + element: , + children: [{ index: true, element: }] }, { path: RoutePath.DiscordConnect, - element: + element: , + children: [{ index: true, element: }] }, { path: RoutePath.DiscordGuide, From 206c1f6a0367f3cec9cf9f928a4b47b2bffcb8e7 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Sat, 10 Aug 2024 00:39:24 +0900 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20username=20=EB=8B=89=EB=84=A4?= =?UTF-8?q?=EC=9E=84=20=EC=9E=98=EB=AA=BB=EB=90=9C=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/guard/VerificationGuard.tsx | 70 ++++++++++--------- .../discordConnect/DiscordNickName.tsx | 2 +- src/pages/DiscordConnect.tsx | 2 +- src/routes/index.tsx | 45 +++++++++--- 4 files changed, 75 insertions(+), 44 deletions(-) diff --git a/src/components/auth/guard/VerificationGuard.tsx b/src/components/auth/guard/VerificationGuard.tsx index 05869a1..223dc83 100644 --- a/src/components/auth/guard/VerificationGuard.tsx +++ b/src/components/auth/guard/VerificationGuard.tsx @@ -1,12 +1,11 @@ import RoutePath from '@/routes/routePath'; -import { isAuthenticated } from '@/utils/auth'; import { toast } from 'react-toastify'; import { useNavigate } from 'react-router-dom'; import { PropsWithChildren, useEffect } from 'react'; import memberApi from '@/apis/member/memberApi'; import { useQuery } from '@tanstack/react-query'; -type GuardType = 'StudentVerification' | 'Discord' | 'SignUp'; +type GuardType = 'StudentVerification' | 'Discord' | 'SignUp' | 'Bevy'; interface VerificationGuardProps extends PropsWithChildren { guardType: GuardType; @@ -18,40 +17,47 @@ export default function VerificationGuard({ children }: VerificationGuardProps) { const navigate = useNavigate(); + const { data } = useQuery({ + queryKey: ['member'], + queryFn: memberApi.GET_DASHBOARD + }); useEffect(() => { - if (isAuthenticated()) { - // eslint-disable-next-line react-hooks/rules-of-hooks - const { data } = useQuery({ - queryKey: ['member'], - queryFn: memberApi.GET_DASHBOARD - }); - if (!data) return; + if (!data) return; - if ( - guardType === 'SignUp' && - data.member.associateRequirement.infoStatus === 'SATISFIED' - ) { - toast.error('기본 정보를 이미 입력했습니다.'); - navigate(RoutePath.Dashboard); - return; - } else if ( - guardType === 'Discord' && - data.member.associateRequirement.discordStatus === 'SATISFIED' - ) { - toast.error('디스코드 연동을 이미 완료했습니다.'); - navigate(RoutePath.Dashboard); - return; - } else if ( - guardType === 'StudentVerification' && - data.member.associateRequirement.univStatus === 'SATISFIED' - ) { - toast.error('재학생 인증을 이미 완료했습니다.'); - navigate(RoutePath.Dashboard); - return; - } + if ( + guardType === 'SignUp' && + data.member.associateRequirement.infoStatus === 'SATISFIED' + ) { + toast.error('기본 정보를 이미 입력했습니다.'); + navigate(RoutePath.Dashboard); + return; } - }, [guardType, navigate]); + if ( + guardType === 'Discord' && + data.member.associateRequirement.discordStatus === 'SATISFIED' + ) { + toast.error('디스코드 연동을 이미 완료했습니다.'); + navigate(RoutePath.Dashboard); + return; + } + if ( + guardType === 'StudentVerification' && + data.member.associateRequirement.univStatus === 'SATISFIED' + ) { + toast.error('재학생 인증을 이미 완료했습니다.'); + navigate(RoutePath.Dashboard); + return; + } + if ( + guardType === 'Bevy' && + data.member.associateRequirement.bevyStatus === 'SATISFIED' + ) { + toast.error('bevy 가입을 이미 완료했습니다.'); + navigate(RoutePath.Dashboard); + return; + } + }, [data, guardType, navigate]); return children; } diff --git a/src/components/discordConnect/DiscordNickName.tsx b/src/components/discordConnect/DiscordNickName.tsx index f8a56f0..62592f9 100644 --- a/src/components/discordConnect/DiscordNickName.tsx +++ b/src/components/discordConnect/DiscordNickName.tsx @@ -31,7 +31,7 @@ export const DiscordNickName = ({ onNext }: { onNext: () => void }) => { const handleNextClick = useCallback(async () => { const isValid = await trigger('discordNickname'); if (isValid) { - checkDuplicate(getValues('discordUsername')); + checkDuplicate(getValues('discordNickname')); } else { setError('discordNickname', { type: 'manual', diff --git a/src/pages/DiscordConnect.tsx b/src/pages/DiscordConnect.tsx index 99221cb..f6027e4 100644 --- a/src/pages/DiscordConnect.tsx +++ b/src/pages/DiscordConnect.tsx @@ -15,7 +15,7 @@ import useCustomBack from '@/hooks/common/useCutomBack'; const steps = ['이름 설정', '별명 설정', '서버 합류', '서버 연동', '연동 완료']; -export const DicordConnect = () => { +export const DiscordConnect = () => { const { Funnel, Step, setStep, currentStep } = useFunnel(steps[0]); const methods = useForm({ diff --git a/src/routes/index.tsx b/src/routes/index.tsx index ef3cdd0..60fff45 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -18,7 +18,7 @@ import { PaymentsFail, PaymentsCheckout } from '@/pages'; -import { DicordConnect } from '@/pages/DiscordConnect'; +import { DiscordConnect } from '@/pages/DiscordConnect'; import { DiscordGuide } from '@/pages/DiscordGuide'; import { Suspense } from 'react'; import PaymentAccessGuard from '@/components/auth/guard/PaymentAccessGuard'; @@ -58,11 +58,11 @@ const router = sentryCreateBrowserRouter([ { index: true, element: ( - - + + - - + + ) } ] @@ -91,13 +91,29 @@ const router = sentryCreateBrowserRouter([ }, { path: RoutePath.Discord, - element: , - children: [{ index: true, element: }] + children: [ + { + index: true, + element: ( + + + + ) + } + ] }, { path: RoutePath.DiscordConnect, - element: , - children: [{ index: true, element: }] + children: [ + { + index: true, + element: ( + + + + ) + } + ] }, { path: RoutePath.DiscordGuide, @@ -105,7 +121,16 @@ const router = sentryCreateBrowserRouter([ }, { path: RoutePath.Bevy, - element: + children: [ + { + index: true, + element: ( + + + + ) + } + ] } ] }, From 47368bf089b9e87e2212a67cadf4a665bb1fa8ca Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Sat, 10 Aug 2024 01:21:46 +0900 Subject: [PATCH 4/8] =?UTF-8?q?fix:=20=EB=8C=80=EA=B8=B0=EC=A4=91=20?= =?UTF-8?q?=EB=AC=B8=EA=B5=AC=EB=A7=8C=20=EB=9C=A8=EB=8A=94=20=EA=B2=83=20?= =?UTF-8?q?=EA=B3=A0=EC=B9=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/discord/discordApi.ts | 2 +- src/components/discordConnect/JoinServer.tsx | 32 ++++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/apis/discord/discordApi.ts b/src/apis/discord/discordApi.ts index 5a795d6..40810f3 100644 --- a/src/apis/discord/discordApi.ts +++ b/src/apis/discord/discordApi.ts @@ -25,7 +25,7 @@ const discordApi = { }); return response.data; }, - GET_DISCORD_JOIN: async (name: string) => { + GET_DISCORD_JOIN: async (name: string): Promise<{ isJoined: boolean }> => { const response = await apiClient.get('/onboarding/check-discord-join', { params: { username: name diff --git a/src/components/discordConnect/JoinServer.tsx b/src/components/discordConnect/JoinServer.tsx index ab14f05..a74d186 100644 --- a/src/components/discordConnect/JoinServer.tsx +++ b/src/components/discordConnect/JoinServer.tsx @@ -13,26 +13,38 @@ const FETCH_INTERVAL = 5000; export const JoinServer = ({ onNext }: { onNext: () => void }) => { const { getValues } = useFormContext(); - const [isEnabled, setIsEnabled] = useState(false); + const [callQuery, setCallQuery] = useState(false); - //NOTE: 처음 렌더링 되었을 때에 바로 fetch 하지 않고 5초 기다린 후에 fetch 합니다. + // 초기에 5초 후에 isEnabled를 true로 설정 useEffect(() => { const timer = setTimeout(() => { - setIsEnabled(true); + setCallQuery(true); }, FETCH_INTERVAL); return () => clearTimeout(timer); }, []); - const { data } = useGetDiscordJoined(getValues('discordUsername'), isEnabled); + const { data, refetch } = useGetDiscordJoined( + getValues('discordUsername'), + callQuery + ); - //NOTE : 합류여부가 true 일 경우에는 더 이상 fetch 하지 않습니다. + // data가 변경될 때마다 refetch를 호출하여 최신 상태를 가져옴 useEffect(() => { - if (data?.isJoined) { - setIsEnabled(false); + if (callQuery) { + refetch(); + } + }, [callQuery, refetch]); + + // data가 변경될 때마다 버튼 상태를 업데이트 + useEffect(() => { + if (data) { + if (data.isJoined) setCallQuery(false); // 합류가 확인되면 더 이상 fetch하지 않음 } }, [data]); + console.log(callQuery); + return ( <> @@ -49,7 +61,7 @@ export const JoinServer = ({ onNext }: { onNext: () => void }) => { window.open(RoutePath.GDSCHongikDiscord, '_blank')} /> @@ -60,8 +72,8 @@ export const JoinServer = ({ onNext }: { onNext: () => void }) => { }} disabled={!data?.isJoined} style={{ maxWidth: '100%' }}> - {!isEnabled - ? '잠시만 기다려주세요.' + {callQuery + ? '합류 여부를 확인 중이에요.' : data?.isJoined ? '합류가 확인되었어요.' : '합류가 확인되지 않았어요.'} From 473037f09a3dbbca3d1febe6b8abb5eeee53cc3c Mon Sep 17 00:00:00 2001 From: SeieunYoo Date: Sun, 11 Aug 2024 00:06:08 +0900 Subject: [PATCH 5/8] =?UTF-8?q?fix:=20console=20log=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/discordConnect/JoinServer.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/discordConnect/JoinServer.tsx b/src/components/discordConnect/JoinServer.tsx index a74d186..a943cc4 100644 --- a/src/components/discordConnect/JoinServer.tsx +++ b/src/components/discordConnect/JoinServer.tsx @@ -43,8 +43,6 @@ export const JoinServer = ({ onNext }: { onNext: () => void }) => { } }, [data]); - console.log(callQuery); - return ( <> From c35a8c5256a5b06b6ac9bfc033ecb8d9491e33b6 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Sun, 11 Aug 2024 15:06:50 +0900 Subject: [PATCH 6/8] =?UTF-8?q?fix:=20=ED=95=A9=EB=A5=98=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=97=AC=EB=B6=80=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/discordConnect/JoinServer.tsx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/components/discordConnect/JoinServer.tsx b/src/components/discordConnect/JoinServer.tsx index a74d186..5f0ddcf 100644 --- a/src/components/discordConnect/JoinServer.tsx +++ b/src/components/discordConnect/JoinServer.tsx @@ -24,27 +24,13 @@ export const JoinServer = ({ onNext }: { onNext: () => void }) => { return () => clearTimeout(timer); }, []); - const { data, refetch } = useGetDiscordJoined( - getValues('discordUsername'), - callQuery - ); - - // data가 변경될 때마다 refetch를 호출하여 최신 상태를 가져옴 - useEffect(() => { - if (callQuery) { - refetch(); - } - }, [callQuery, refetch]); + const { data } = useGetDiscordJoined(getValues('discordUsername'), callQuery); // data가 변경될 때마다 버튼 상태를 업데이트 useEffect(() => { - if (data) { - if (data.isJoined) setCallQuery(false); // 합류가 확인되면 더 이상 fetch하지 않음 - } + setCallQuery(false); }, [data]); - console.log(callQuery); - return ( <> From 5b7d0aa741dcfd72d1a2b334d8d77d19082f50a1 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Sun, 11 Aug 2024 15:07:54 +0900 Subject: [PATCH 7/8] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/discordConnect/JoinServer.tsx | 1 - src/utils/auth.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/discordConnect/JoinServer.tsx b/src/components/discordConnect/JoinServer.tsx index 5f0ddcf..3dccdec 100644 --- a/src/components/discordConnect/JoinServer.tsx +++ b/src/components/discordConnect/JoinServer.tsx @@ -26,7 +26,6 @@ export const JoinServer = ({ onNext }: { onNext: () => void }) => { const { data } = useGetDiscordJoined(getValues('discordUsername'), callQuery); - // data가 변경될 때마다 버튼 상태를 업데이트 useEffect(() => { setCallQuery(false); }, [data]); diff --git a/src/utils/auth.ts b/src/utils/auth.ts index ec3524b..2b15bb4 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1,6 +1,5 @@ export const isAuthenticated = () => { const isLogin = sessionStorage.getItem('isLogin'); - if (isLogin === 'true') return true; - else return false; + return isLogin === 'true'; }; From 1cc4856ad9c586fd10daefe3d9b044bd83f35a42 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Sun, 11 Aug 2024 15:13:28 +0900 Subject: [PATCH 8/8] =?UTF-8?q?fix:joinServer=20=EC=95=88=EB=82=B4?= =?UTF-8?q?=EB=AC=B8=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/discordConnect/JoinServer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/discordConnect/JoinServer.tsx b/src/components/discordConnect/JoinServer.tsx index 3dccdec..0b1f1f8 100644 --- a/src/components/discordConnect/JoinServer.tsx +++ b/src/components/discordConnect/JoinServer.tsx @@ -27,7 +27,7 @@ export const JoinServer = ({ onNext }: { onNext: () => void }) => { const { data } = useGetDiscordJoined(getValues('discordUsername'), callQuery); useEffect(() => { - setCallQuery(false); + if (data?.isJoined) setCallQuery(false); }, [data]); return (