diff --git a/apps/jurumarble/src/app/my/edit/components/UserInfoEditContainer.tsx b/apps/jurumarble/src/app/my/edit/components/UserInfoEditContainer.tsx index 49765649..110de3c6 100644 --- a/apps/jurumarble/src/app/my/edit/components/UserInfoEditContainer.tsx +++ b/apps/jurumarble/src/app/my/edit/components/UserInfoEditContainer.tsx @@ -60,15 +60,14 @@ function UserInfoEditContainer() { variant="primary" width="100%" height="56px" - onClick={() => { + onClick={() => updateUserInfo({ nickname, alcoholLimit, mbti, imageUrl, - }); - router.push(Path.MY_PAGE); - }} + }) + } > 완료 diff --git a/apps/jurumarble/src/app/my/edit/services/useEditProfileService.ts b/apps/jurumarble/src/app/my/edit/services/useEditProfileService.ts index 18792080..b925e79e 100644 --- a/apps/jurumarble/src/app/my/edit/services/useEditProfileService.ts +++ b/apps/jurumarble/src/app/my/edit/services/useEditProfileService.ts @@ -1,7 +1,10 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { uploadImageAPI } from "lib/apis/common"; import { deleteUserAPI, updateUserInfoAPI } from "lib/apis/my"; +import Path from "lib/Path"; import { queryKeys } from "lib/queryKeys"; +import { useRouter } from "next/navigation"; +import { toast } from "react-toastify"; type UpdateUserInfoRequest = Exclude[0], undefined>; @@ -39,9 +42,12 @@ export default function useEditProfileService() { queryClient.setQueryData(getQueryKey, (prev: any) => ({ ...prev, mbti: value })); }; + const router = useRouter(); + const { mutate: updateUserInfo } = useMutation( (newUserInfo: UpdateUserInfoRequest) => updateUserInfoAPI(newUserInfo), { + onSuccess: () => router.push(Path.MY_PAGE), onError: () => { /** * @TODO 서버 메시지와 연동 @@ -51,7 +57,12 @@ export default function useEditProfileService() { }, ); - const { mutate: deleteUser } = useMutation(() => deleteUserAPI()); + const { mutate: deleteUser } = useMutation(() => deleteUserAPI(), { + onSuccess: () => { + toast("회원 탈퇴가 완료되었습니다."); + router.push(Path.MAIN_PAGE); + }, + }); return { onUploadImage, diff --git a/apps/jurumarble/src/app/register/contexts/RegisterProvider.tsx b/apps/jurumarble/src/app/register/contexts/RegisterProvider.tsx index 93a77253..25cfbff9 100644 --- a/apps/jurumarble/src/app/register/contexts/RegisterProvider.tsx +++ b/apps/jurumarble/src/app/register/contexts/RegisterProvider.tsx @@ -86,6 +86,16 @@ export const RegisterProvider = ({ children }: PropsWithChildren) => { : 1; const onNextStep = () => { + if (Number(yearOfBirth) > 2004) { + toast.error("2004년 이후 출생자는 가입이 불가능합니다."); + setYearOfBirth(""); + return; + } else if (999 < Number(yearOfBirth) && Number(yearOfBirth) < 1900) { + toast.error("출생년도를 다시 한번 확인해주세요."); + setYearOfBirth(""); + return; + } + currentStepIndex < stepList.length ? setStep(stepList[currentStepIndex]) : onToggleWarningModal(); @@ -141,11 +151,7 @@ export const RegisterProvider = ({ children }: PropsWithChildren) => { } else if (step === "STEP2") { return gender === null; } else if (step === "STEP3") { - /** - * @TODO 토스트 메시지가 두번씩 뜨는 이슈 - */ - Number(yearOfBirth) > 2004 && toast.error("2004년 이후 출생자는 가입이 불가능합니다."); - return yearOfBirth === "" || yearOfBirth?.length !== 4 || Number(yearOfBirth) > 2004; + return yearOfBirth === "" || yearOfBirth?.length !== 4; } else if (step === "STEP4") { return Object.values(MBTI).some((value) => value === null); }