Skip to content

Commit

Permalink
fix: username 닉네임 잘못된 부분 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene028 committed Aug 9, 2024
1 parent ca30a99 commit 206c1f6
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 44 deletions.
70 changes: 38 additions & 32 deletions src/components/auth/guard/VerificationGuard.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion src/components/discordConnect/DiscordNickName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DiscordConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DiscordFormValues>({
Expand Down
45 changes: 35 additions & 10 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -58,11 +58,11 @@ const router = sentryCreateBrowserRouter([
{
index: true,
element: (
<Suspense fallback="..loading">
<VerificationGuard guardType="StudentVerification">
<VerificationGuard guardType="StudentVerification">
<Suspense fallback="..loading">
<StudentVerification />
</VerificationGuard>
</Suspense>
</Suspense>
</VerificationGuard>
)
}
]
Expand Down Expand Up @@ -91,21 +91,46 @@ const router = sentryCreateBrowserRouter([
},
{
path: RoutePath.Discord,
element: <VerificationGuard guardType="Discord" />,
children: [{ index: true, element: <JoinDiscord /> }]
children: [
{
index: true,
element: (
<VerificationGuard guardType="Discord">
<JoinDiscord />
</VerificationGuard>
)
}
]
},
{
path: RoutePath.DiscordConnect,
element: <VerificationGuard guardType="Discord" />,
children: [{ index: true, element: <DicordConnect /> }]
children: [
{
index: true,
element: (
<VerificationGuard guardType="Discord">
<DiscordConnect />
</VerificationGuard>
)
}
]
},
{
path: RoutePath.DiscordGuide,
element: <DiscordGuide />
},
{
path: RoutePath.Bevy,
element: <Bevy />
children: [
{
index: true,
element: (
<VerificationGuard guardType="Bevy">
<Bevy />
</VerificationGuard>
)
}
]
}
]
},
Expand Down

0 comments on commit 206c1f6

Please sign in to comment.