From 73f4647ec59e4bdbd4f00bf7b2c981887e0b30ce Mon Sep 17 00:00:00 2001 From: Joywin Bennis <107112207+joywin2003@users.noreply.github.com> Date: Sun, 24 Nov 2024 19:29:28 +0530 Subject: [PATCH 1/4] fix: validate coupon code length and handle empty input in registration form --- src/components/common/registration-form.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/common/registration-form.tsx b/src/components/common/registration-form.tsx index 1d02a94..64f1bdd 100644 --- a/src/components/common/registration-form.tsx +++ b/src/components/common/registration-form.tsx @@ -220,6 +220,13 @@ export default function RegistrationForm() { const verifyCoupon = async () => { const couponCode = form.getValues("couponCode"); + if (!couponCode) { + return; + } + if (couponCode.length !== 10) { + toast.error("Invalid Coupon Code"); + return; + } try { const result = await getPrice(couponCode); if (!result.success) { @@ -535,7 +542,7 @@ export default function RegistrationForm() {