From 6dd4ac7d1d9e6b8e661cb24e9164cf46d8a1de31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EA=B4=91=EB=AF=BC?= Date: Sun, 3 Aug 2025 09:37:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20?= =?UTF-8?q?=EA=B2=80=EC=82=AC=20=EB=A1=9C=EC=A7=81=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=ED=99=94=20=EB=B0=8F=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=EC=A1=B0=EA=B1=B4=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../signup/components/SignupForm.tsx | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/app/(non-header)/signup/components/SignupForm.tsx b/src/app/(non-header)/signup/components/SignupForm.tsx index 2b6ed6ec..dd4f5057 100644 --- a/src/app/(non-header)/signup/components/SignupForm.tsx +++ b/src/app/(non-header)/signup/components/SignupForm.tsx @@ -60,9 +60,23 @@ export default function SignupForm() { passwordConfirmation: '', }); - const hasErrors = Object.values(errors).some((msg) => msg !== ''); - const isAllFilled = email && nickname && password && passwordConfirmation; - const isDisabled = !isAllFilled || hasErrors; + const validateAll = () => ({ + email: validateEmail(email), + nickname: validateNickname(nickname), + password: validatePassword(password), + passwordConfirmation: validatePasswordConfirmation( + passwordConfirmation, + password, + ), + }); + + const hasErrors = (errs: typeof errors) => + Object.values(errs).some((msg) => msg !== ''); + + const isAllFilled = () => + email && nickname && password && passwordConfirmation; + + const disabled = !isAllFilled() || hasErrors(errors); const [errorPopupOpen, setErrorPopupOpen] = useState(false); const [errorMessage, setErrorMessage] = useState(''); @@ -85,6 +99,22 @@ export default function SignupForm() { } }, [state, setUser]); + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + + const newErrors = validateAll(); + setErrors(newErrors); + + if (!isAllFilled() || hasErrors(newErrors)) return; + + const formData = new FormData(); + formData.append('email', email); + formData.append('nickname', nickname); + formData.append('password', password); + + formAction(formData); + }; + /** * 카카오 회원가입 버튼 클릭 시 실행되는 함수입니다. * 환경변수에서 리디렉션 URI와 클라이언트 ID를 읽어, @@ -121,7 +151,7 @@ export default function SignupForm() { -
+
회원가입 하기 From a086da792d8443aca65dcfbe064d790093e84760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EA=B4=91=EB=AF=BC?= Date: Sun, 3 Aug 2025 09:37:26 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=ED=8C=9D=EC=97=85=20=EC=97=B4?= =?UTF-8?q?=EB=A6=B4=20=EB=95=8C=20=ED=99=95=EC=9D=B8=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=EC=97=90=20=EC=9E=90=EB=8F=99=20=ED=8F=AC=EC=BB=A4=EC=8A=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Popup.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Popup.tsx b/src/components/Popup.tsx index e44e13c0..50f03427 100644 --- a/src/components/Popup.tsx +++ b/src/components/Popup.tsx @@ -67,6 +67,7 @@ export default function Popup({ 'text-md h-42 w-138 rounded-lg font-medium md:h-48 md:w-120 md:self-end md:text-lg', )} onClick={onClose} + autoFocus > 확인