Skip to content

Commit

Permalink
[비즈니스] validation 수정 (#380)
Browse files Browse the repository at this point in the history
* fix: validation 추가 및 수정

* fix: PC버전에서 음식점 검색 제외

* feat; isFormError 상태값 변경
  • Loading branch information
kimeodml authored Jul 23, 2024
1 parent 06fe848 commit ac39eb6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
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
17 changes: 16 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,21 @@ export default function Login() {
});

const onSubmit: SubmitHandler<LoginParams> = async (data) => {
if (data.account === '') {
setLoginError('전화번호를 입력해주세요.');
setIsFormError(true);
return;
}
if (data.password === '') {
setLoginError('비밀번호를 입력해주세요.');
setIsFormError(true);
return;
}
if (!/^[0-9]*$/.test(data.account)) {
setLoginError('올바른 전화번호 형식이 아닙니다.');
setIsFormError(true);
return;
}
const hashedPassword = await sha256(data.password);
login({ account: data.account, password: hashedPassword, isAutoLogin });
};
Expand Down
19 changes: 1 addition & 18 deletions src/page/ShopRegistration/view/PC/ShopConfirmation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ReactComponent as Logo } from 'assets/svg/auth/koin-logo.svg';
import { ReactComponent as Cutlery } from 'assets/svg/shopRegistration/cutlery.svg';
import Copyright from 'component/common/Copyright';
import Category from 'page/ShopRegistration/component/Modal/Category';
import SearchShop from 'page/ShopRegistration/component/Modal/SearchShop';
import OperateTimePC from 'page/ShopRegistration/component/Modal/OperateTimePC';
import ConfirmPopup from 'page/ShopRegistration/component/ConfirmPopup';
import CustomModal from 'component/common/CustomModal';
Expand Down Expand Up @@ -36,11 +35,6 @@ export default function ShopConfirmation({ onNext }:{ onNext: () => void }) {
setTrue: openOperateTime,
setFalse: closeOperateTime,
} = useBooleanState(false);
const {
value: showSearchShop,
setTrue: openSearchShop,
setFalse: closeSearchShop,
} = useBooleanState(false);
const {
value: showConfirmPopup,
setTrue: openConfirmPopup,
Expand Down Expand Up @@ -204,24 +198,13 @@ export default function ShopConfirmation({ onNext }:{ onNext: () => void }) {
<div className={styles.form__section}>
<input
type="text"
className={styles.form__input}
className={styles['form__input-large']}
value={name}
{...register('name', { required: true })}
/>
<CustomButton content="가게검색" buttonSize="small" onClick={openSearchShop} />
</div>
{isError && name === '' && <ErrorMessage message={ERRORMESSAGE.name} />}
</div>
<CustomModal
title="가게검색"
modalSize="large"
hasFooter={false}
isOverflowVisible={false}
isOpen={showSearchShop}
onCancel={closeSearchShop}
>
<SearchShop open={showSearchShop} onCancel={closeSearchShop} />
</CustomModal>
<div>
<span className={styles.form__title}>주소정보</span>
<div className={styles.form__section}>
Expand Down

0 comments on commit ac39eb6

Please sign in to comment.