From ac39eb67c16b7feae6ce0265441262b1a87c3a64 Mon Sep 17 00:00:00 2001 From: Daeeui Kim Date: Tue, 23 Jul 2024 23:04:04 +0900 Subject: [PATCH] =?UTF-8?q?[=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4]=20valida?= =?UTF-8?q?tion=20=EC=88=98=EC=A0=95=20(#380)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: validation 추가 및 수정 * fix: PC버전에서 음식점 검색 제외 * feat; isFormError 상태값 변경 --- src/page/Auth/Login/Login.module.scss | 6 ++++++ src/page/Auth/Login/index.tsx | 17 ++++++++++++++++- .../view/PC/ShopConfirmation/index.tsx | 19 +------------------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/page/Auth/Login/Login.module.scss b/src/page/Auth/Login/Login.module.scss index 7cc8d471..e626875c 100644 --- a/src/page/Auth/Login/Login.module.scss +++ b/src/page/Auth/Login/Login.module.scss @@ -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 { diff --git a/src/page/Auth/Login/index.tsx b/src/page/Auth/Login/index.tsx index ee3313aa..58c7dacd 100644 --- a/src/page/Auth/Login/index.tsx +++ b/src/page/Auth/Login/index.tsx @@ -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; @@ -36,6 +36,21 @@ export default function Login() { }); const onSubmit: SubmitHandler = 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 }); }; diff --git a/src/page/ShopRegistration/view/PC/ShopConfirmation/index.tsx b/src/page/ShopRegistration/view/PC/ShopConfirmation/index.tsx index d73a8f70..592b880c 100644 --- a/src/page/ShopRegistration/view/PC/ShopConfirmation/index.tsx +++ b/src/page/ShopRegistration/view/PC/ShopConfirmation/index.tsx @@ -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'; @@ -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, @@ -204,24 +198,13 @@ export default function ShopConfirmation({ onNext }:{ onNext: () => void }) {
-
{isError && name === '' && } - - -
주소정보