Skip to content

Commit

Permalink
Merge pull request #97 from CoolPeace-yanolza/feature/#96
Browse files Browse the repository at this point in the history
[#96] 로그인 유효성 검사 로직 수정
  • Loading branch information
dabin-Hailey authored Jan 24, 2024
2 parents ba5480b + 83b93fb commit 895ebad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions src/components/Login/LoginForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const LoginForm = () => {
formState: { errors, isValid },
handleSubmit
} = methods;
const isError = !!errors?.user_id || !!errors?.user_password ? true : false;
const isError = !!errors?.login_id || !!errors?.login_password ? true : false;

const movetoSignUp = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
Expand All @@ -38,8 +38,8 @@ const LoginForm = () => {

const onSubmit: SubmitHandler<FieldValues> = async data => {
const formData: LoginData = {
email: data.user_id,
password: data.user_password
email: data.login_id,
password: data.login_password
};
try {
const response = await postLogin(formData);
Expand Down Expand Up @@ -69,26 +69,26 @@ const LoginForm = () => {
<Inputs $isValid={!isError}>
<AuthInputNormal
type="email"
id="user_id"
id="login_id"
placeholder="이메일 입력"
usedFor="login"
isError={!!errors?.user_id}
isError={!!errors?.login_id}
/>
<AuthInputPassword
id="user_password"
id="login_password"
placeholder="비밀번호 입력"
usedFor="login"
isError={!!errors?.user_password}
isError={!!errors?.login_password}
/>
</Inputs>
{errors.user_id && (
{errors.login_id && (
<ValidationText>
{errors?.user_id?.message?.toString()}
{errors?.login_id?.message?.toString()}
</ValidationText>
)}
{!errors.user_id && errors.user_password && (
{!errors.login_id && errors.login_password && (
<ValidationText>
{errors?.user_password?.message?.toString()}
{errors?.login_password?.message?.toString()}
</ValidationText>
)}
<Buttons $isValid={!isError}>
Expand Down
12 changes: 6 additions & 6 deletions src/utils/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export const getInputOptions = (inputName: string, password?: string) => {
}
}
};
case 'user_id':
case 'login_id':
return {
required: '아이디를 입력해주세요.',
pattern: {
value: emailRegex,
message: '이메일 형식에 맞게 입력해주세요.'
}
required: '아이디를 입력해주세요.'
};
case 'login_password':
return {
required: '비밀번호를 입력해주세요.'
};
}
};

0 comments on commit 895ebad

Please sign in to comment.