From 36a530b8d7aecdbae2569efb0c50691921a41c38 Mon Sep 17 00:00:00 2001 From: Urvish Date: Mon, 16 Nov 2026 15:22:19 +0530 Subject: [PATCH] fix(checkout): validate and display duplicate mobile number errors in billing phone modal --- src/App.tsx | 5 +++-- src/components/checkout/BillingPhoneModal.tsx | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index af1024d..2d26b5f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -438,8 +438,9 @@ export default function App() { } return false; } catch (err: any) { - alert(err.response?.data?.detail || 'Failed to save billing phone number.'); - return false; + const errorMsg = err.response?.data?.detail || 'Failed to save billing phone number.'; + alert(errorMsg); + throw new Error(errorMsg); } }; diff --git a/src/components/checkout/BillingPhoneModal.tsx b/src/components/checkout/BillingPhoneModal.tsx index db4637a..d0e2418 100644 --- a/src/components/checkout/BillingPhoneModal.tsx +++ b/src/components/checkout/BillingPhoneModal.tsx @@ -54,10 +54,15 @@ export const BillingPhoneModal: React.FC = ({ setSaving(true); const e164 = formatE164Phone(dialCode, phone); - const success = await onSavePhone(e164, country); - setSaving(false); - if (success) { - onClose(); + try { + const success = await onSavePhone(e164, country); + if (success) { + onClose(); + } + } catch (err: any) { + setError(err?.message || 'Failed to save billing phone number.'); + } finally { + setSaving(false); } };