Skip to content

Commit

Permalink
Merge pull request #860 from KEEPER31337/feature/helper_text_constant…
Browse files Browse the repository at this point in the history
…s로_빼기_#847

refactor : CONFIRM_PASSWORD_MSG 적용
  • Loading branch information
jasper200207 committed Dec 11, 2023
2 parents e9c8d25 + 510d7d1 commit 4cb60ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/pages/Profile/Modal/EditAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useWithdrawalMutation,
} from '@api/memberApi';
import { useCheckEmailDuplicationQuery } from '@api/signUpApi';
import { COMMON, EMAIL_MSG, PASSWORD_MSG } from '@constants/helperText';
import { COMMON, EMAIL_MSG, CONFIRM_PASSWORD_MSG } from '@constants/helperText';
import memberState from '@recoil/member.recoil';
import { emailRegex } from '@utils/validateEmail';
import FilledButton from '@components/Button/FilledButton';
Expand Down Expand Up @@ -233,7 +233,7 @@ const EditPasswordSection = () => {
},
pattern: {
value: /^(?=.*[a-zA-Z])(?=.*[0-9]).{8,20}$/,
message: PASSWORD_MSG.error.formatError,
message: CONFIRM_PASSWORD_MSG.error.formatError,
},
}}
render={({ field, fieldState: { error } }) => {
Expand All @@ -257,8 +257,8 @@ const EditPasswordSection = () => {
required: COMMON.error.required,
validate: {
confirmMatchPassward: (value) => {
if (getValues('newPassword') !== value) return PASSWORD_MSG.error.incorrect;
setPasswordConfirmSuccessMsg(PASSWORD_MSG.success.correct);
if (getValues('newPassword') !== value) return CONFIRM_PASSWORD_MSG.error.mismatch;
setPasswordConfirmSuccessMsg(CONFIRM_PASSWORD_MSG.success.match);
return undefined;
},
},
Expand Down
8 changes: 4 additions & 4 deletions src/pages/SignUp/Section/SignUpFirstInputSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { VscCheck } from 'react-icons/vsc';
import { useSetRecoilState } from 'recoil';

import { signUpKeys, useCheckLoginIdDuplicationQuery } from '@api/signUpApi';
import { COMMON, LOGIN_ID_MSG, PASSWORD_MSG } from '@constants/helperText';
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';
Expand Down Expand Up @@ -115,7 +115,7 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp
},
pattern: {
value: /^(?=.*[a-zA-Z])(?=.*[0-9]).{8,20}$/,
message: PASSWORD_MSG.error.formatError,
message: CONFIRM_PASSWORD_MSG.error.formatError,
},
}}
render={({ field, fieldState: { error } }) => {
Expand All @@ -139,8 +139,8 @@ const SignUpFirstInputSection = ({ setCurrentStep }: SignUpFirstInputSectionProp
required: COMMON.error.required,
validate: {
confirmMatchPassward: (value) => {
if (getValues('password') !== value) return PASSWORD_MSG.error.incorrect;
setPasswordConfirmSuccessMsg(PASSWORD_MSG.success.correct);
if (getValues('password') !== value) return CONFIRM_PASSWORD_MSG.error.mismatch;
setPasswordConfirmSuccessMsg(CONFIRM_PASSWORD_MSG.success.match);
return undefined;
},
},
Expand Down
8 changes: 4 additions & 4 deletions src/pages/login/Search/SearchPWSecondStep.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { Divider } from '@mui/material';
import { useChangePasswordMutation } from '@api/SearchAccountApi';
import { PASSWORD_MSG } from '@constants/helperText';
import { CONFIRM_PASSWORD_MSG } from '@constants/helperText';
import OutlinedButton from '@components/Button/OutlinedButton';
import StandardInput from '@components/Input/StandardInput';

Expand Down Expand Up @@ -46,11 +46,11 @@ const SearchPWSecondStep = ({ setCurrentStep, firstForm }: SearchPWSecondStepPro
const handleBlur = (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement, Element>) => {
const { name, value } = e.currentTarget;
if (name === 'newPassword') {
if (value && !passwordRegex.test(value)) setPasswordErrorMsg(PASSWORD_MSG.error.formatError);
if (value && !passwordRegex.test(value)) setPasswordErrorMsg(CONFIRM_PASSWORD_MSG.error.formatError);
}
if (name === 'confirmPassword') {
if (!(value.length > 0 && isSame)) {
setConfirmPasswordErrorMsg(PASSWORD_MSG.error.incorrect);
setConfirmPasswordErrorMsg(CONFIRM_PASSWORD_MSG.error.mismatch);
}
}
};
Expand Down Expand Up @@ -113,7 +113,7 @@ const SearchPWSecondStep = ({ setCurrentStep, firstForm }: SearchPWSecondStepPro
onChange={handleChange}
onBlur={handleBlur}
error={Boolean(confirmPasswordErrorMsg)}
helperText={confirmPasswordErrorMsg || (isSame && PASSWORD_MSG.success.correct)}
helperText={confirmPasswordErrorMsg || (isSame && CONFIRM_PASSWORD_MSG.success.match)}
/>
</div>
</div>
Expand Down

0 comments on commit 4cb60ab

Please sign in to comment.