From 3d22a66c82956da8f23801d15f57543b9ba8a06a Mon Sep 17 00:00:00 2001 From: yunsung Date: Fri, 6 Dec 2024 15:47:58 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A3=BC=EB=AC=B8=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EC=97=90=EC=84=9C=20=EB=AA=A8=EB=93=A0=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=B4=EC=95=BC?= =?UTF-8?q?=EB=A7=8C=20=EA=B2=B0=EC=A0=9C=20=EA=B0=80=EB=8A=A5=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95(#14)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pages/Payment/PaymentForm.tsx | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/components/pages/Payment/PaymentForm.tsx b/src/components/pages/Payment/PaymentForm.tsx index bdf4158..8cf32c5 100644 --- a/src/components/pages/Payment/PaymentForm.tsx +++ b/src/components/pages/Payment/PaymentForm.tsx @@ -33,6 +33,30 @@ const PaymentForm = () => { const [needed, setNeeded] = useState(''); const [payment, setPayment] = useState(''); + const validateForm = () => { + if (!userName.trim()) { + alert('수령인을 입력해주세요.'); + return false; + } + if (!basicAddress.trim()) { + alert('기본 주소를 입력해주세요.'); + return false; + } + if (!detailAddress.trim()) { + alert('상세 주소를 입력해주세요.'); + return false; + } + if (!needed.trim()) { + alert('배송 시 요청사항을 입력해주세요.'); + return false; + } + if (!payment) { + alert('결제 방법을 선택해주세요.'); + return false; + } + return true; + }; + const payload = { productName: product.name, url: product.url, @@ -52,6 +76,9 @@ const PaymentForm = () => { setPayment(e.target.value); }; const onPaymentSubmit = async () => { + if (!validateForm()) { + return; + } try { const paymentResult = await handlePayment(productId, payload);