Skip to content

Commit

Permalink
fix: validation 추가 및 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kimeodml committed Jul 23, 2024
1 parent 06fe848 commit 3249f81
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/page/Auth/Login/Login.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@
}

&__error-message {
display: flex;
width: calc(100% - 90px);
font-size: 12px;
color: #f7941e;

@include media.media-breakpoint-down(mobile) {
width: 100%;
}
}

&__icon {
Expand Down
14 changes: 13 additions & 1 deletion src/page/Auth/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Login() {
const { login, isError: isServerError } = useLogin();
const [isFormError, setIsFormError] = useState(false);
const navigate = useNavigate();
const { loginError, loginErrorStatus } = useErrorMessageStore();
const { loginError, setLoginError, loginErrorStatus } = useErrorMessageStore();
const [emailError, setEmailError] = useState('');
const isError = isServerError || isFormError;

Expand All @@ -36,6 +36,18 @@ export default function Login() {
});

const onSubmit: SubmitHandler<LoginParams> = async (data) => {
if (data.account === '') {
setLoginError('전화번호를 입력해주세요.');
return;
}
if (data.password === '') {
setLoginError('비밀번호를 입력해주세요.');
return;
}
if (!/^[0-9]*$/.test(data.account)) {
setLoginError('올바른 전화번호 형식이 아닙니다.');
return;
}
const hashedPassword = await sha256(data.password);
login({ account: data.account, password: hashedPassword, isAutoLogin });
};
Expand Down

0 comments on commit 3249f81

Please sign in to comment.