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: ( + + + + ) + } + ] } ] },