Skip to content

Commit

Permalink
fix: 주문페이지에서 모든 정보를 작성해야만 결제 가능하도록 수정(#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
cho1ys committed Dec 6, 2024
1 parent 24e9c0e commit 3d22a66
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/components/pages/Payment/PaymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -52,6 +76,9 @@ const PaymentForm = () => {
setPayment(e.target.value);
};
const onPaymentSubmit = async () => {
if (!validateForm()) {
return;
}
try {
const paymentResult = await handlePayment(productId, payload);

Expand Down

0 comments on commit 3d22a66

Please sign in to comment.