From 9847b6945cf720d1d8a3c4abeb554a33b1b17bbe Mon Sep 17 00:00:00 2001 From: munkyeong Date: Sun, 10 Dec 2023 19:40:31 +0900 Subject: [PATCH 1/7] =?UTF-8?q?refactor=20:=20api=20=EA=B4=80=EB=A0=A8=20e?= =?UTF-8?q?rror/success=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/memberApi.ts | 9 +-- src/api/postApi.ts | 7 ++- src/api/seminarApi.ts | 3 +- src/constants/apiResponseMsg.ts | 57 +++++++++++++++++++ src/pages/Profile/Modal/EditAccountModal.tsx | 5 +- .../Section/SignUpFirstInputSection.tsx | 3 +- .../Section/SignUpThirdInputSection.tsx | 3 +- .../senimarAttend/Card/MemberCardContent.tsx | 5 +- 8 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 src/constants/apiResponseMsg.ts diff --git a/src/api/memberApi.ts b/src/api/memberApi.ts index 93a5dec59..1c73a8451 100644 --- a/src/api/memberApi.ts +++ b/src/api/memberApi.ts @@ -4,6 +4,7 @@ import axios from 'axios'; import { useApiError } from '@hooks/useGetApiError'; import { formatGeneration } from '@utils/converter'; import { ProfileInfo, MemberDetailInfo } from './dto'; +import { PASSWORD } from '@constants/apiResponseMsg'; const memberKeys = { memberList: ['member', 'memberList'] as const, @@ -123,7 +124,7 @@ const useEditEmailMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error('현재 비밀번호가 일치하지 않습니다.'); + toast.error(PASSWORD.error.passwordMismatch); }, }, }); @@ -138,7 +139,7 @@ const useEditPasswordMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error('현재 비밀번호가 일치하지 않습니다.'); + toast.error(PASSWORD.error.passwordMismatch); }, }, }); @@ -147,7 +148,7 @@ const useEditPasswordMutation = () => { return useMutation(fetcher, { onSuccess: () => { - toast.success('비밀번호가 변경되었습니다.'); + toast.success(PASSWORD.success.changedSuccess); }, onError: (err) => handleError(err, 400), }); @@ -157,7 +158,7 @@ const useWithdrawalMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error('비밀번호가 일치하지 않습니다.'); + toast.error(PASSWORD.error.passwordMismatch); }, }, }); diff --git a/src/api/postApi.ts b/src/api/postApi.ts index f3d08cad7..c0840f665 100644 --- a/src/api/postApi.ts +++ b/src/api/postApi.ts @@ -15,6 +15,7 @@ import { PageAndSize, MemberPost, } from './dto'; +import { POST } from '@constants/apiResponseMsg'; const postKeys = { memberPost: (param: PageAndSize & { memberId: number }) => ['memberPost', param] as const, @@ -151,12 +152,12 @@ const useGetEachPostQuery = ( 400: { default: () => { // TODO 페이지 문구로 띄워주기 - toast.error('게시글 열람 조건을 충족하지 않습니다.'); + toast.error(POST.error.readCondition); }, }, 403: { 40301: () => { - toast.error('게시글의 비밀번호가 일치하지 않습니다.'); + toast.error(POST.error.passwordMismatch); }, 40302: () => { // 비밀글 여부 true로 변경 @@ -226,7 +227,7 @@ const useDownloadFileMutation = () => { }, onError: (error) => { if ((error as AxiosError)?.response?.status === 400) { - toast.error('댓글 작성이 필요합니다.'); + toast.error(POST.error.commentRequired); } }, }); diff --git a/src/api/seminarApi.ts b/src/api/seminarApi.ts index d5ba3ac12..715199805 100644 --- a/src/api/seminarApi.ts +++ b/src/api/seminarApi.ts @@ -3,6 +3,7 @@ import axios from 'axios'; import { DateTime } from 'luxon'; import { useApiError } from '@hooks/useGetApiError'; import { AttendSeminarListInfo, SeminarStatus, SeminarInfo, SeminarCardInfo } from './dto'; +import { SEMINAR } from '@constants/apiResponseMsg'; const seminarKeys = { getSeminarList: ['getSeminar', 'seminarList'] as const, @@ -143,7 +144,7 @@ const useAddSeminarMutation = ({ setHelperText }: { setHelperText: React.Dispatc const { handleError } = useApiError({ 409: { 40901: () => { - setHelperText('동일한 날짜의 세미나는 생성할 수 없습니다.'); + setHelperText(SEMINAR.error.duplicateSeminarDate); }, }, }); diff --git a/src/constants/apiResponseMsg.ts b/src/constants/apiResponseMsg.ts new file mode 100644 index 000000000..a0a2ab4ca --- /dev/null +++ b/src/constants/apiResponseMsg.ts @@ -0,0 +1,57 @@ +export const COMMON = {} as const; + +export const PASSWORD = { + success: { + changedSuccess: '비밀번호가 변경되었습니다.', + }, + error: { + passwordMismatch: '현재 비밀번호가 일치하지 않습니다.', + }, +} as const; + +export const POST = { + success: {}, + error: { + readCondition: '게시글 열람 조건을 충족하지 않습니다.', + passwordMismatch: '게시글의 비밀번호가 일치하지 않습니다.', + commentRequired: '댓글 작성이 필요합니다.', + }, +} as const; + +export const SEMINAR = { + success: {}, + error: { + duplicateSeminarDate: '동일한 날짜의 세미나는 생성할 수 없습니다.', + }, +} as const; + +export const EMAIL = { + success: { + changedSuccess: '이메일 변경 성공하였습니다.', + }, + error: { + existingEmail: '이미 존재하는 이메일입니다.', + }, +} as const; + +export const MEMBER_CARD = { + success: {}, + error: { + noSubmissionsLeft: '남은 제출 횟수가 없습니다.', + invalidAttendanceWithCount: (min: number) => `출석코드가 틀렸습니다. (남은 제출횟수 ${min}회)` as const, + }, +} as const; + +export const ID = { + success: {}, + errror: { + existingId: '이미 존재하는 아이디입니다.', + }, +}; + +export const StudentID = { + success: {}, + errror: { + existingStudentId: '이미 존재하는 학번입니다.', + }, +}; diff --git a/src/pages/Profile/Modal/EditAccountModal.tsx b/src/pages/Profile/Modal/EditAccountModal.tsx index 589e83c07..41cb5ff50 100644 --- a/src/pages/Profile/Modal/EditAccountModal.tsx +++ b/src/pages/Profile/Modal/EditAccountModal.tsx @@ -23,6 +23,7 @@ import EmailAuthInput from '@components/Input/EmailAuthInput'; import StandardInput from '@components/Input/StandardInput'; import TimerInput from '@components/Input/TimerInput'; import ConfirmModal from '@components/Modal/ConfirmModal'; +import { EMAIL } from '@constants/apiResponseMsg'; const EditEmailSection = () => { const [expirationTime, setExpirationTime] = useState(null); @@ -57,7 +58,7 @@ const EditEmailSection = () => { { email, auth, password }, { onSuccess: () => { - toast.success('이메일 변경 성공하였습니다.'); + toast.success(EMAIL.success.changedSuccess); setIsEmailSent(false); reset(); }, @@ -69,7 +70,7 @@ const EditEmailSection = () => { if (!checkEmailDuplicationSuccess) return; if (isEmailDuplicate.duplicate === true) { - setError('email', { message: '이미 존재하는 이메일입니다.' }); + setError('email', { message: EMAIL.error.existingEmail }); setIsEmailSent(false); return; } diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index 26ae00350..6399fb171 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -10,6 +10,7 @@ import FilledButton from '@components/Button/FilledButton'; import OutlinedButton from '@components/Button/OutlinedButton'; import StandardInput from '@components/Input/StandardInput'; import signUpPageState from '../SignUp.recoil'; +import { ID } from '@constants/apiResponseMsg'; interface SignUpFirstInputSectionProps { setCurrentStep: React.Dispatch>; @@ -50,7 +51,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp if (!isLoginIdDuplicate) return; if (isLoginIdDuplicate.duplicate === true) { - setError('loginId', { message: '이미 존재하는 아이디입니다.' }); + setError('loginId', { message: ID.errror.existingId }); setCheckLoginIdDuplicateEnabled(false); } }, [isLoginIdDuplicate]); diff --git a/src/pages/SignUp/Section/SignUpThirdInputSection.tsx b/src/pages/SignUp/Section/SignUpThirdInputSection.tsx index 0d32074e4..f09a399ac 100644 --- a/src/pages/SignUp/Section/SignUpThirdInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpThirdInputSection.tsx @@ -13,6 +13,7 @@ import EmailAuthInput from '@components/Input/EmailAuthInput'; import TimerInput from '@components/Input/TimerInput'; import MailAuthenticationModal from '@components/Modal/MailAuthenticationModal'; import signUpPageState from '../SignUp.recoil'; +import { EMAIL } from '@constants/apiResponseMsg'; const SignUpThirdInputSection = () => { const [expirationTime, setExpirationTime] = useState(null); @@ -73,7 +74,7 @@ const SignUpThirdInputSection = () => { if (!checkEmailDuplicationSuccess) return; if (isEmailDuplicate.duplicate === true) { - setError('email', { message: '이미 존재하는 이메일입니다.' }); + setError('email', { message: EMAIL.error.existingEmail }); setIsEmailSent(false); return; } diff --git a/src/pages/senimarAttend/Card/MemberCardContent.tsx b/src/pages/senimarAttend/Card/MemberCardContent.tsx index c8ead08ea..85b6a30bc 100644 --- a/src/pages/senimarAttend/Card/MemberCardContent.tsx +++ b/src/pages/senimarAttend/Card/MemberCardContent.tsx @@ -11,6 +11,7 @@ import Countdown from '../Countdown/Countdown'; import SeminarInput from '../Input/SeminarInput'; import SeminarAttendStatus from '../Status/SeminarAttendStatus'; import attendCountState from '../seminarAttend.recoil'; +import { MEMBER_CARD } from '@constants/apiResponseMsg'; interface ErrorResponse { message: string; @@ -51,10 +52,10 @@ const MemberCardContent = ({ seminarId }: { seminarId: number }) => { if (remainAttendCount <= 0) { setExcessModalOpen(true); - setIncorrectCodeMsg('남은 제출 횟수가 없습니다.'); + setIncorrectCodeMsg(MEMBER_CARD.error.noSubmissionsLeft); return; } - setIncorrectCodeMsg(`출석코드가 틀렸습니다. (남은 제출횟수 ${remainAttendCount}회)`); + setIncorrectCodeMsg(MEMBER_CARD.error.invalidAttendanceWithCount(remainAttendCount)); return; } const errorMessage = axiosError?.response?.data?.message; From d3fcba8c8808d9eeefc9effa5895abfd4b8dc157 Mon Sep 17 00:00:00 2001 From: munkyeong Date: Mon, 11 Dec 2023 19:31:44 +0900 Subject: [PATCH 2/7] =?UTF-8?q?refactor=20:=20import=20=EC=9C=84=EC=B9=98?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20PR=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/memberApi.ts | 10 +++++----- src/api/postApi.ts | 2 +- src/api/seminarApi.ts | 2 +- .../{apiResponseMsg.ts => apiResponseMessage.ts} | 14 +++++++------- src/pages/Profile/Modal/EditAccountModal.tsx | 4 ++-- .../SignUp/Section/SignUpFirstInputSection.tsx | 4 ++-- .../SignUp/Section/SignUpSecondInputSection.tsx | 3 ++- .../SignUp/Section/SignUpThirdInputSection.tsx | 2 +- src/pages/senimarAttend/Card/MemberCardContent.tsx | 2 +- 9 files changed, 22 insertions(+), 21 deletions(-) rename src/constants/{apiResponseMsg.ts => apiResponseMessage.ts} (78%) diff --git a/src/api/memberApi.ts b/src/api/memberApi.ts index 1c73a8451..d9b15733c 100644 --- a/src/api/memberApi.ts +++ b/src/api/memberApi.ts @@ -1,10 +1,10 @@ import toast from 'react-hot-toast'; import { useQuery, useMutation, useQueryClient } from 'react-query'; import axios from 'axios'; +import { PASSWORD } from '@constants/apiResponseMessage'; import { useApiError } from '@hooks/useGetApiError'; import { formatGeneration } from '@utils/converter'; import { ProfileInfo, MemberDetailInfo } from './dto'; -import { PASSWORD } from '@constants/apiResponseMsg'; const memberKeys = { memberList: ['member', 'memberList'] as const, @@ -124,7 +124,7 @@ const useEditEmailMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error(PASSWORD.error.passwordMismatch); + toast.error(PASSWORD.error.mismatchPassword); }, }, }); @@ -139,7 +139,7 @@ const useEditPasswordMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error(PASSWORD.error.passwordMismatch); + toast.error(PASSWORD.error.mismatchPassword); }, }, }); @@ -148,7 +148,7 @@ const useEditPasswordMutation = () => { return useMutation(fetcher, { onSuccess: () => { - toast.success(PASSWORD.success.changedSuccess); + toast.success(PASSWORD.success.changed); }, onError: (err) => handleError(err, 400), }); @@ -158,7 +158,7 @@ const useWithdrawalMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error(PASSWORD.error.passwordMismatch); + toast.error(PASSWORD.error.mismatchPassword); }, }, }); diff --git a/src/api/postApi.ts b/src/api/postApi.ts index c0840f665..caa50a9b7 100644 --- a/src/api/postApi.ts +++ b/src/api/postApi.ts @@ -2,6 +2,7 @@ import toast from 'react-hot-toast'; import { useMutation, useQuery, useQueryClient } from 'react-query'; import { useLocation, useNavigate } from 'react-router-dom'; import axios, { AxiosError } from 'axios'; +import { POST } from '@constants/apiResponseMessage'; import { useApiError } from '@hooks/useGetApiError'; import { BoardPosts, @@ -15,7 +16,6 @@ import { PageAndSize, MemberPost, } from './dto'; -import { POST } from '@constants/apiResponseMsg'; const postKeys = { memberPost: (param: PageAndSize & { memberId: number }) => ['memberPost', param] as const, diff --git a/src/api/seminarApi.ts b/src/api/seminarApi.ts index 715199805..5523d10d1 100644 --- a/src/api/seminarApi.ts +++ b/src/api/seminarApi.ts @@ -1,9 +1,9 @@ import { useQuery, useMutation, useQueryClient } from 'react-query'; import axios from 'axios'; import { DateTime } from 'luxon'; +import { SEMINAR } from '@constants/apiResponseMessage'; import { useApiError } from '@hooks/useGetApiError'; import { AttendSeminarListInfo, SeminarStatus, SeminarInfo, SeminarCardInfo } from './dto'; -import { SEMINAR } from '@constants/apiResponseMsg'; const seminarKeys = { getSeminarList: ['getSeminar', 'seminarList'] as const, diff --git a/src/constants/apiResponseMsg.ts b/src/constants/apiResponseMessage.ts similarity index 78% rename from src/constants/apiResponseMsg.ts rename to src/constants/apiResponseMessage.ts index a0a2ab4ca..36cbf4646 100644 --- a/src/constants/apiResponseMsg.ts +++ b/src/constants/apiResponseMessage.ts @@ -2,10 +2,10 @@ export const COMMON = {} as const; export const PASSWORD = { success: { - changedSuccess: '비밀번호가 변경되었습니다.', + changed: '비밀번호가 변경되었습니다.', }, error: { - passwordMismatch: '현재 비밀번호가 일치하지 않습니다.', + mismatchPassword: '현재 비밀번호가 일치하지 않습니다.', }, } as const; @@ -27,7 +27,7 @@ export const SEMINAR = { export const EMAIL = { success: { - changedSuccess: '이메일 변경 성공하였습니다.', + changed: '이메일 변경 성공하였습니다.', }, error: { existingEmail: '이미 존재하는 이메일입니다.', @@ -38,20 +38,20 @@ export const MEMBER_CARD = { success: {}, error: { noSubmissionsLeft: '남은 제출 횟수가 없습니다.', - invalidAttendanceWithCount: (min: number) => `출석코드가 틀렸습니다. (남은 제출횟수 ${min}회)` as const, + invalidAttendanceWithCount: (min: number) => `출석코드가 틀렸습니다. (남은 제출횟수 ${min}회)`, }, } as const; export const ID = { success: {}, - errror: { + error: { existingId: '이미 존재하는 아이디입니다.', }, }; -export const StudentID = { +export const STUDENT_ID = { success: {}, - errror: { + error: { existingStudentId: '이미 존재하는 학번입니다.', }, }; diff --git a/src/pages/Profile/Modal/EditAccountModal.tsx b/src/pages/Profile/Modal/EditAccountModal.tsx index 41cb5ff50..f0ea11913 100644 --- a/src/pages/Profile/Modal/EditAccountModal.tsx +++ b/src/pages/Profile/Modal/EditAccountModal.tsx @@ -14,6 +14,7 @@ import { useWithdrawalMutation, } from '@api/memberApi'; import { useCheckEmailDuplicationQuery } from '@api/signUpApi'; +import { EMAIL } from '@constants/apiResponseMessage'; import { REQUIRE_ERROR_MSG } from '@constants/errorMsg'; import memberState from '@recoil/member.recoil'; import { emailRegex } from '@utils/validateEmail'; @@ -23,7 +24,6 @@ import EmailAuthInput from '@components/Input/EmailAuthInput'; import StandardInput from '@components/Input/StandardInput'; import TimerInput from '@components/Input/TimerInput'; import ConfirmModal from '@components/Modal/ConfirmModal'; -import { EMAIL } from '@constants/apiResponseMsg'; const EditEmailSection = () => { const [expirationTime, setExpirationTime] = useState(null); @@ -58,7 +58,7 @@ const EditEmailSection = () => { { email, auth, password }, { onSuccess: () => { - toast.success(EMAIL.success.changedSuccess); + toast.success(EMAIL.success.changed); setIsEmailSent(false); reset(); }, diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index 6399fb171..5a95344b6 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -6,11 +6,11 @@ import { VscCheck } from 'react-icons/vsc'; import { useSetRecoilState } from 'recoil'; import { signUpKeys, useCheckLoginIdDuplicationQuery } from '@api/signUpApi'; +import { ID } from '@constants/apiResponseMessage'; import FilledButton from '@components/Button/FilledButton'; import OutlinedButton from '@components/Button/OutlinedButton'; import StandardInput from '@components/Input/StandardInput'; import signUpPageState from '../SignUp.recoil'; -import { ID } from '@constants/apiResponseMsg'; interface SignUpFirstInputSectionProps { setCurrentStep: React.Dispatch>; @@ -51,7 +51,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp if (!isLoginIdDuplicate) return; if (isLoginIdDuplicate.duplicate === true) { - setError('loginId', { message: ID.errror.existingId }); + setError('loginId', { message: ID.error.existingId }); setCheckLoginIdDuplicateEnabled(false); } }, [isLoginIdDuplicate]); diff --git a/src/pages/SignUp/Section/SignUpSecondInputSection.tsx b/src/pages/SignUp/Section/SignUpSecondInputSection.tsx index 8e454ffc2..3a9f72fdd 100644 --- a/src/pages/SignUp/Section/SignUpSecondInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpSecondInputSection.tsx @@ -5,6 +5,7 @@ import { Stack } from '@mui/material'; import { VscCheck } from 'react-icons/vsc'; import { useSetRecoilState } from 'recoil'; import { signUpKeys, useCheckStudentIdDuplicationQuery } from '@api/signUpApi'; +import { STUDENT_ID } from '@constants/apiResponseMessage'; import { NUMBER_ERROR_MSG, REQUIRE_ERROR_MSG } from '@constants/errorMsg'; import FilledButton from '@components/Button/FilledButton'; import OutlinedButton from '@components/Button/OutlinedButton'; @@ -57,7 +58,7 @@ const SignUpSecondInputSection = ({ setCurrentStep }: SignUpFirstInputSectionPro if (!isStudentIdDuplicate) return; if (isStudentIdDuplicate.duplicate === true) { - setError('studentId', { message: '이미 존재하는 학번입니다.' }); + setError('studentId', { message: STUDENT_ID.error.existingStudentId }); setCheckStudentIdDuplicateEnabled(false); } }, [isStudentIdDuplicate]); diff --git a/src/pages/SignUp/Section/SignUpThirdInputSection.tsx b/src/pages/SignUp/Section/SignUpThirdInputSection.tsx index f09a399ac..d7844de1e 100644 --- a/src/pages/SignUp/Section/SignUpThirdInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpThirdInputSection.tsx @@ -6,6 +6,7 @@ import { Stack, Typography } from '@mui/material'; import { DateTime } from 'luxon'; import { useRecoilValue } from 'recoil'; import { useCheckEmailDuplicationQuery, useEmailAuthMutation, useSignUpMutation } from '@api/signUpApi'; +import { EMAIL } from '@constants/apiResponseMessage'; import { REQUIRE_ERROR_MSG } from '@constants/errorMsg'; import { emailRegex } from '@utils/validateEmail'; import OutlinedButton from '@components/Button/OutlinedButton'; @@ -13,7 +14,6 @@ import EmailAuthInput from '@components/Input/EmailAuthInput'; import TimerInput from '@components/Input/TimerInput'; import MailAuthenticationModal from '@components/Modal/MailAuthenticationModal'; import signUpPageState from '../SignUp.recoil'; -import { EMAIL } from '@constants/apiResponseMsg'; const SignUpThirdInputSection = () => { const [expirationTime, setExpirationTime] = useState(null); diff --git a/src/pages/senimarAttend/Card/MemberCardContent.tsx b/src/pages/senimarAttend/Card/MemberCardContent.tsx index 85b6a30bc..a9c01e6f4 100644 --- a/src/pages/senimarAttend/Card/MemberCardContent.tsx +++ b/src/pages/senimarAttend/Card/MemberCardContent.tsx @@ -5,13 +5,13 @@ import { DateTime } from 'luxon'; import { useRecoilState } from 'recoil'; import { SeminarStatus } from '@api/dto'; import { useAttendSeminarMutation, useGetAvailableSeminarInfoQuery, useGetSeminarInfoQuery } from '@api/seminarApi'; +import { MEMBER_CARD } from '@constants/apiResponseMessage'; import FilledButton from '@components/Button/FilledButton'; import ConfirmModal from '@components/Modal/ConfirmModal'; import Countdown from '../Countdown/Countdown'; import SeminarInput from '../Input/SeminarInput'; import SeminarAttendStatus from '../Status/SeminarAttendStatus'; import attendCountState from '../seminarAttend.recoil'; -import { MEMBER_CARD } from '@constants/apiResponseMsg'; interface ErrorResponse { message: string; From 9772c16f4382ffaceb37db13513b492729ca2d20 Mon Sep 17 00:00:00 2001 From: munkyeong Date: Mon, 11 Dec 2023 19:35:15 +0900 Subject: [PATCH 3/7] refactor : mismatchPassword to mismatch --- src/api/memberApi.ts | 6 +++--- src/constants/apiResponseMessage.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/memberApi.ts b/src/api/memberApi.ts index d9b15733c..ded70c331 100644 --- a/src/api/memberApi.ts +++ b/src/api/memberApi.ts @@ -124,7 +124,7 @@ const useEditEmailMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error(PASSWORD.error.mismatchPassword); + toast.error(PASSWORD.error.mismatch); }, }, }); @@ -139,7 +139,7 @@ const useEditPasswordMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error(PASSWORD.error.mismatchPassword); + toast.error(PASSWORD.error.mismatch); }, }, }); @@ -158,7 +158,7 @@ const useWithdrawalMutation = () => { const { handleError } = useApiError({ 400: { default: () => { - toast.error(PASSWORD.error.mismatchPassword); + toast.error(PASSWORD.error.mismatch); }, }, }); diff --git a/src/constants/apiResponseMessage.ts b/src/constants/apiResponseMessage.ts index 36cbf4646..efb65508f 100644 --- a/src/constants/apiResponseMessage.ts +++ b/src/constants/apiResponseMessage.ts @@ -5,7 +5,7 @@ export const PASSWORD = { changed: '비밀번호가 변경되었습니다.', }, error: { - mismatchPassword: '현재 비밀번호가 일치하지 않습니다.', + mismatch: '현재 비밀번호가 일치하지 않습니다.', }, } as const; From 396f7b0daa30d2c3e2eecd61691ce6a6dcac4c31 Mon Sep 17 00:00:00 2001 From: munkyeong Date: Mon, 11 Dec 2023 19:40:21 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor=20:=20=EB=B0=B1=ED=8B=B1=EC=9D=B4?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=EB=90=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?as=20const=20=EC=84=A0=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/constants/apiResponseMessage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/apiResponseMessage.ts b/src/constants/apiResponseMessage.ts index efb65508f..25f46984b 100644 --- a/src/constants/apiResponseMessage.ts +++ b/src/constants/apiResponseMessage.ts @@ -38,7 +38,7 @@ export const MEMBER_CARD = { success: {}, error: { noSubmissionsLeft: '남은 제출 횟수가 없습니다.', - invalidAttendanceWithCount: (min: number) => `출석코드가 틀렸습니다. (남은 제출횟수 ${min}회)`, + invalidAttendanceWithCount: (min: number) => `출석코드가 틀렸습니다. (남은 제출횟수 ${min}회)` as const, }, } as const; From 3d35fd63a54b7e4d9018158896130c59e3b5e69f Mon Sep 17 00:00:00 2001 From: munkyeong Date: Mon, 11 Dec 2023 19:49:37 +0900 Subject: [PATCH 5/7] =?UTF-8?q?refactor=20:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/postApi.ts | 4 ++-- src/constants/apiResponseMessage.ts | 10 +++++----- src/pages/Profile/Modal/EditAccountModal.tsx | 2 +- src/pages/SignUp/Section/SignUpFirstInputSection.tsx | 2 +- src/pages/SignUp/Section/SignUpSecondInputSection.tsx | 2 +- src/pages/SignUp/Section/SignUpThirdInputSection.tsx | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/api/postApi.ts b/src/api/postApi.ts index caa50a9b7..6f1fac2f8 100644 --- a/src/api/postApi.ts +++ b/src/api/postApi.ts @@ -157,7 +157,7 @@ const useGetEachPostQuery = ( }, 403: { 40301: () => { - toast.error(POST.error.passwordMismatch); + toast.error(POST.error.mismatchPassword); }, 40302: () => { // 비밀글 여부 true로 변경 @@ -227,7 +227,7 @@ const useDownloadFileMutation = () => { }, onError: (error) => { if ((error as AxiosError)?.response?.status === 400) { - toast.error(POST.error.commentRequired); + toast.error(POST.error.requiredComment); } }, }); diff --git a/src/constants/apiResponseMessage.ts b/src/constants/apiResponseMessage.ts index 25f46984b..6eea1f5e6 100644 --- a/src/constants/apiResponseMessage.ts +++ b/src/constants/apiResponseMessage.ts @@ -13,8 +13,8 @@ export const POST = { success: {}, error: { readCondition: '게시글 열람 조건을 충족하지 않습니다.', - passwordMismatch: '게시글의 비밀번호가 일치하지 않습니다.', - commentRequired: '댓글 작성이 필요합니다.', + mismatchPassword: '게시글의 비밀번호가 일치하지 않습니다.', + requiredComment: '댓글 작성이 필요합니다.', }, } as const; @@ -30,7 +30,7 @@ export const EMAIL = { changed: '이메일 변경 성공하였습니다.', }, error: { - existingEmail: '이미 존재하는 이메일입니다.', + existing: '이미 존재하는 이메일입니다.', }, } as const; @@ -45,13 +45,13 @@ export const MEMBER_CARD = { export const ID = { success: {}, error: { - existingId: '이미 존재하는 아이디입니다.', + existing: '이미 존재하는 아이디입니다.', }, }; export const STUDENT_ID = { success: {}, error: { - existingStudentId: '이미 존재하는 학번입니다.', + existing: '이미 존재하는 학번입니다.', }, }; diff --git a/src/pages/Profile/Modal/EditAccountModal.tsx b/src/pages/Profile/Modal/EditAccountModal.tsx index f0ea11913..3163170c3 100644 --- a/src/pages/Profile/Modal/EditAccountModal.tsx +++ b/src/pages/Profile/Modal/EditAccountModal.tsx @@ -70,7 +70,7 @@ const EditEmailSection = () => { if (!checkEmailDuplicationSuccess) return; if (isEmailDuplicate.duplicate === true) { - setError('email', { message: EMAIL.error.existingEmail }); + setError('email', { message: EMAIL.error.existing }); setIsEmailSent(false); return; } diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index 5a95344b6..389fc3916 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -51,7 +51,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp if (!isLoginIdDuplicate) return; if (isLoginIdDuplicate.duplicate === true) { - setError('loginId', { message: ID.error.existingId }); + setError('loginId', { message: ID.error.existing }); setCheckLoginIdDuplicateEnabled(false); } }, [isLoginIdDuplicate]); diff --git a/src/pages/SignUp/Section/SignUpSecondInputSection.tsx b/src/pages/SignUp/Section/SignUpSecondInputSection.tsx index 3a9f72fdd..d84f1644c 100644 --- a/src/pages/SignUp/Section/SignUpSecondInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpSecondInputSection.tsx @@ -58,7 +58,7 @@ const SignUpSecondInputSection = ({ setCurrentStep }: SignUpFirstInputSectionPro if (!isStudentIdDuplicate) return; if (isStudentIdDuplicate.duplicate === true) { - setError('studentId', { message: STUDENT_ID.error.existingStudentId }); + setError('studentId', { message: STUDENT_ID.error.existing }); setCheckStudentIdDuplicateEnabled(false); } }, [isStudentIdDuplicate]); diff --git a/src/pages/SignUp/Section/SignUpThirdInputSection.tsx b/src/pages/SignUp/Section/SignUpThirdInputSection.tsx index d7844de1e..2005bccb0 100644 --- a/src/pages/SignUp/Section/SignUpThirdInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpThirdInputSection.tsx @@ -74,7 +74,7 @@ const SignUpThirdInputSection = () => { if (!checkEmailDuplicationSuccess) return; if (isEmailDuplicate.duplicate === true) { - setError('email', { message: EMAIL.error.existingEmail }); + setError('email', { message: EMAIL.error.existing }); setIsEmailSent(false); return; } From fdc445ed1974bc9c563dd0ca806d5af4b72cd463 Mon Sep 17 00:00:00 2001 From: munkyeong Date: Mon, 11 Dec 2023 20:15:30 +0900 Subject: [PATCH 6/7] =?UTF-8?q?refactor=20:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20PR=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/postApi.ts | 8 ++++---- src/constants/apiResponseMessage.ts | 6 +++--- src/pages/SignUp/Section/SignUpFirstInputSection.tsx | 4 ++-- src/pages/senimarAttend/Card/MemberCardContent.tsx | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/api/postApi.ts b/src/api/postApi.ts index 6f1fac2f8..905c57370 100644 --- a/src/api/postApi.ts +++ b/src/api/postApi.ts @@ -2,7 +2,7 @@ import toast from 'react-hot-toast'; import { useMutation, useQuery, useQueryClient } from 'react-query'; import { useLocation, useNavigate } from 'react-router-dom'; import axios, { AxiosError } from 'axios'; -import { POST } from '@constants/apiResponseMessage'; +import { BOARD } from '@constants/apiResponseMessage'; import { useApiError } from '@hooks/useGetApiError'; import { BoardPosts, @@ -152,12 +152,12 @@ const useGetEachPostQuery = ( 400: { default: () => { // TODO 페이지 문구로 띄워주기 - toast.error(POST.error.readCondition); + toast.error(BOARD.error.readCondition); }, }, 403: { 40301: () => { - toast.error(POST.error.mismatchPassword); + toast.error(BOARD.error.mismatchPassword); }, 40302: () => { // 비밀글 여부 true로 변경 @@ -227,7 +227,7 @@ const useDownloadFileMutation = () => { }, onError: (error) => { if ((error as AxiosError)?.response?.status === 400) { - toast.error(POST.error.requiredComment); + toast.error(BOARD.error.requiredComment); } }, }); diff --git a/src/constants/apiResponseMessage.ts b/src/constants/apiResponseMessage.ts index 6eea1f5e6..9453302c4 100644 --- a/src/constants/apiResponseMessage.ts +++ b/src/constants/apiResponseMessage.ts @@ -9,7 +9,7 @@ export const PASSWORD = { }, } as const; -export const POST = { +export const BOARD = { success: {}, error: { readCondition: '게시글 열람 조건을 충족하지 않습니다.', @@ -38,11 +38,11 @@ export const MEMBER_CARD = { success: {}, error: { noSubmissionsLeft: '남은 제출 횟수가 없습니다.', - invalidAttendanceWithCount: (min: number) => `출석코드가 틀렸습니다. (남은 제출횟수 ${min}회)` as const, + mismatchWithCount: (min: number) => `출석코드가 틀렸습니다. (남은 제출횟수 ${min}회)` as const, }, } as const; -export const ID = { +export const LOGIN_ID = { success: {}, error: { existing: '이미 존재하는 아이디입니다.', diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index 389fc3916..71ec8d2ac 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -6,7 +6,7 @@ import { VscCheck } from 'react-icons/vsc'; import { useSetRecoilState } from 'recoil'; import { signUpKeys, useCheckLoginIdDuplicationQuery } from '@api/signUpApi'; -import { ID } from '@constants/apiResponseMessage'; +import { LOGIN_ID } from '@constants/apiResponseMessage'; import FilledButton from '@components/Button/FilledButton'; import OutlinedButton from '@components/Button/OutlinedButton'; import StandardInput from '@components/Input/StandardInput'; @@ -51,7 +51,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp if (!isLoginIdDuplicate) return; if (isLoginIdDuplicate.duplicate === true) { - setError('loginId', { message: ID.error.existing }); + setError('loginId', { message: LOGIN_ID.error.existing }); setCheckLoginIdDuplicateEnabled(false); } }, [isLoginIdDuplicate]); diff --git a/src/pages/senimarAttend/Card/MemberCardContent.tsx b/src/pages/senimarAttend/Card/MemberCardContent.tsx index a9c01e6f4..0e3ed25c7 100644 --- a/src/pages/senimarAttend/Card/MemberCardContent.tsx +++ b/src/pages/senimarAttend/Card/MemberCardContent.tsx @@ -55,7 +55,7 @@ const MemberCardContent = ({ seminarId }: { seminarId: number }) => { setIncorrectCodeMsg(MEMBER_CARD.error.noSubmissionsLeft); return; } - setIncorrectCodeMsg(MEMBER_CARD.error.invalidAttendanceWithCount(remainAttendCount)); + setIncorrectCodeMsg(MEMBER_CARD.error.mismatchWithCount(remainAttendCount)); return; } const errorMessage = axiosError?.response?.data?.message; From daab57ed878cdd37114c17e927f63c8c64e1b049 Mon Sep 17 00:00:00 2001 From: munkyeong Date: Mon, 11 Dec 2023 20:50:13 +0900 Subject: [PATCH 7/7] =?UTF-8?q?confilct=20:=20=EC=B6=A9=EB=8F=8C=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/SignUp/Section/SignUpFirstInputSection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx index 47693aae9..ec1aeb68c 100644 --- a/src/pages/SignUp/Section/SignUpFirstInputSection.tsx +++ b/src/pages/SignUp/Section/SignUpFirstInputSection.tsx @@ -6,8 +6,8 @@ import { VscCheck } from 'react-icons/vsc'; import { useSetRecoilState } from 'recoil'; import { signUpKeys, useCheckLoginIdDuplicationQuery } from '@api/signUpApi'; -import { COMMON, LOGIN_ID_MSG, CONFIRM_PASSWORD_MSG } from '@constants/helperText'; import { LOGIN_ID } from '@constants/apiResponseMessage'; +import { COMMON, LOGIN_ID_MSG, CONFIRM_PASSWORD_MSG } from '@constants/helperText'; import FilledButton from '@components/Button/FilledButton'; import OutlinedButton from '@components/Button/OutlinedButton'; import StandardInput from '@components/Input/StandardInput';