From 4429a4cc01cf3615eb5a5fe36a63c0bfd4ae6d19 Mon Sep 17 00:00:00 2001 From: publdaze Date: Thu, 28 Dec 2023 19:00:19 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor=20:=20signUp=20api=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=ED=82=A4=20=ED=8F=AC=EB=A7=B7=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #863 --- src/api/signUpApi.ts | 21 +++++++++++-------- .../Section/SignUpFirstInputSection.tsx | 3 ++- .../Section/SignUpSecondInputSection.tsx | 3 ++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/api/signUpApi.ts b/src/api/signUpApi.ts index bfdd9516c..07839fce9 100644 --- a/src/api/signUpApi.ts +++ b/src/api/signUpApi.ts @@ -3,9 +3,9 @@ import axios from 'axios'; import { SignUpDuplication, SignUpInfo } from './dto'; export const signUpKeys = { - idDuplication: (loginId: string) => ['sighUp', 'duplication', 'loginId', loginId] as const, - emailDuplication: (email: string) => ['sighUp', 'duplication', 'email', email] as const, - studentIdDuplication: (studentId: string) => ['sighUp', 'duplication', 'studentId', studentId] as const, + idDuplication: (params: { loginId: string }) => ['sighUp', 'duplication', 'loginId', params] as const, + emailDuplication: (params: { email: string }) => ['sighUp', 'duplication', 'email', params] as const, + studentIdDuplication: (params: { studentId: string }) => ['sighUp', 'duplication', 'studentId', params] as const, }; const useSignUpMutation = () => { @@ -21,21 +21,24 @@ const useEmailAuthMutation = () => { }; const useCheckLoginIdDuplicationQuery = ({ loginId, enabled }: { loginId: string; enabled: boolean }) => { - const fetcher = () => axios.get('/sign-up/exists/login-id', { params: { loginId } }).then(({ data }) => data); + const params = { loginId }; + const fetcher = () => axios.get('/sign-up/exists/login-id', { params }).then(({ data }) => data); - return useQuery(signUpKeys.idDuplication(loginId), fetcher, { enabled }); + return useQuery(signUpKeys.idDuplication(params), fetcher, { enabled }); }; const useCheckEmailDuplicationQuery = ({ email, enabled }: { email: string; enabled: boolean }) => { - const fetcher = () => axios.get('/sign-up/exists/email', { params: { email } }).then(({ data }) => data); + const params = { email }; + const fetcher = () => axios.get('/sign-up/exists/email', { params }).then(({ data }) => data); - return useQuery(signUpKeys.emailDuplication(email), fetcher, { enabled }); + return useQuery(signUpKeys.emailDuplication(params), fetcher, { enabled }); }; const useCheckStudentIdDuplicationQuery = ({ studentId, enabled }: { studentId: string; enabled: boolean }) => { - const fetcher = () => axios.get('/sign-up/exists/student-id', { params: { studentId } }).then(({ data }) => data); + const params = { studentId }; + const fetcher = () => axios.get('/sign-up/exists/student-id', { params }).then(({ data }) => data); - return useQuery(signUpKeys.studentIdDuplication(studentId), fetcher, { enabled }); + return useQuery(signUpKeys.studentIdDuplication(params), fetcher, { enabled }); }; export { diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index ec1aeb68c..7e46ca135 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -18,6 +18,7 @@ interface SignUpFirstInputSectionProps { } const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProps) => { + // REVIEW useForm 사용하는데 별도의 state가 필요한 지 점검 필요 const [loginIdState, setLoginIdState] = useState(''); const [checkLoginIdDuplicateEnabled, setCheckLoginIdDuplicateEnabled] = useState(false); const [passwordConfirmSuccessMsg, setPasswordConfirmSuccessMsg] = useState(''); @@ -62,7 +63,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp if (isLoginIdDuplicate.duplicate === false) { setCheckLoginIdDuplicateEnabled(false); - queryClient.setQueryData(signUpKeys.idDuplication(loginIdState), undefined); + queryClient.setQueryData(signUpKeys.idDuplication({ loginId: loginIdState }), undefined); } }, [watch('loginId')]); diff --git a/src/pages/SignUp/Section/SignUpSecondInputSection.tsx b/src/pages/SignUp/Section/SignUpSecondInputSection.tsx index b9b08f42f..35afb77a1 100644 --- a/src/pages/SignUp/Section/SignUpSecondInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpSecondInputSection.tsx @@ -20,6 +20,7 @@ interface SignUpFirstInputSectionProps { } const SignUpSecondInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProps) => { + // REVIEW useForm 사용하는데 별도의 state가 필요한 지 점검 필요 const [studentIdState, setStudentIdState] = useState(''); const [checkStudentIdDuplicateEnabled, setCheckStudentIdDuplicateEnabled] = useState(false); const setSignUpPageState = useSetRecoilState(signUpPageState); @@ -68,7 +69,7 @@ const SignUpSecondInputSection = ({ setCurrentStep }: SignUpFirstInputSectionPro if (isStudentIdDuplicate.duplicate === false) { setCheckStudentIdDuplicateEnabled(false); - queryClient.setQueryData(signUpKeys.studentIdDuplication(studentIdState), undefined); + queryClient.setQueryData(signUpKeys.studentIdDuplication({ studentId: studentIdState }), undefined); } }, [watch('studentId')]); From 59f2113f32cd49fe75e72c8b7f5eb47b718284e8 Mon Sep 17 00:00:00 2001 From: publdaze Date: Thu, 28 Dec 2023 19:46:34 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor=20:=20=EC=98=A4=ED=83=80=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 --- src/pages/Profile/Modal/EditAccountModal.tsx | 2 +- src/pages/SignUp/Section/SignUpFirstInputSection.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Profile/Modal/EditAccountModal.tsx b/src/pages/Profile/Modal/EditAccountModal.tsx index 2cde6ec3b..1a783f09c 100644 --- a/src/pages/Profile/Modal/EditAccountModal.tsx +++ b/src/pages/Profile/Modal/EditAccountModal.tsx @@ -257,7 +257,7 @@ const EditPasswordSection = () => { rules={{ required: COMMON.error.required, validate: { - confirmMatchPassward: (value) => { + confirmMatchPassword: (value) => { if (getValues('newPassword') !== value) return CONFIRM_PASSWORD_MSG.error.mismatch; setPasswordConfirmSuccessMsg(CONFIRM_PASSWORD_MSG.success.match); return undefined; diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index 7e46ca135..fa69c6089 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -140,7 +140,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp rules={{ required: COMMON.error.required, validate: { - confirmMatchPassward: (value) => { + confirmMatchPassword: (value) => { if (getValues('password') !== value) return CONFIRM_PASSWORD_MSG.error.mismatch; setPasswordConfirmSuccessMsg(CONFIRM_PASSWORD_MSG.success.match); return undefined; From e3ac14327f219d82d4a667578b38af52fbb0aed2 Mon Sep 17 00:00:00 2001 From: publdaze Date: Tue, 16 Jan 2024 21:10:15 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor=20:=20api=20url=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/signUpApi.ts | 10 ++++++---- src/pages/SignUp/Section/SignUpFirstInputSection.tsx | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api/signUpApi.ts b/src/api/signUpApi.ts index 07839fce9..510109d30 100644 --- a/src/api/signUpApi.ts +++ b/src/api/signUpApi.ts @@ -3,9 +3,11 @@ import axios from 'axios'; import { SignUpDuplication, SignUpInfo } from './dto'; export const signUpKeys = { - idDuplication: (params: { loginId: string }) => ['sighUp', 'duplication', 'loginId', params] as const, - emailDuplication: (params: { email: string }) => ['sighUp', 'duplication', 'email', params] as const, - studentIdDuplication: (params: { studentId: string }) => ['sighUp', 'duplication', 'studentId', params] as const, + base: ['sighUp'] as const, + duplication: () => [...signUpKeys.base, 'exists'] as const, + loginIdDuplication: (params: { loginId: string }) => [...signUpKeys.duplication(), 'loginId', params] as const, + emailDuplication: (params: { email: string }) => [...signUpKeys.duplication(), 'email', params] as const, + studentIdDuplication: (params: { studentId: string }) => [...signUpKeys.duplication(), 'studentId', params] as const, }; const useSignUpMutation = () => { @@ -24,7 +26,7 @@ const useCheckLoginIdDuplicationQuery = ({ loginId, enabled }: { loginId: string const params = { loginId }; const fetcher = () => axios.get('/sign-up/exists/login-id', { params }).then(({ data }) => data); - return useQuery(signUpKeys.idDuplication(params), fetcher, { enabled }); + return useQuery(signUpKeys.loginIdDuplication(params), fetcher, { enabled }); }; const useCheckEmailDuplicationQuery = ({ email, enabled }: { email: string; enabled: boolean }) => { diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index fa69c6089..875ce3f85 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -63,7 +63,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp if (isLoginIdDuplicate.duplicate === false) { setCheckLoginIdDuplicateEnabled(false); - queryClient.setQueryData(signUpKeys.idDuplication({ loginId: loginIdState }), undefined); + queryClient.setQueryData(signUpKeys.loginIdDuplication({ loginId: loginIdState }), undefined); } }, [watch('loginId')]);