From 94d0b3498fd16c8b300a8264b9fc39072746a134 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Thu, 26 Mar 2026 20:27:07 +0100 Subject: [PATCH] feat: add country and vat id fields to checkout flow --- app/welcome/page.tsx | 63 +++++++++++- components/PricingSection.tsx | 185 +++++++++++++++++++++++++++++----- 2 files changed, 221 insertions(+), 27 deletions(-) diff --git a/app/welcome/page.tsx b/app/welcome/page.tsx index 55065f6..e30ee61 100644 --- a/app/welcome/page.tsx +++ b/app/welcome/page.tsx @@ -102,6 +102,10 @@ function WelcomeContent() { const [hadPendingCheckout, setHadPendingCheckout] = useState(null) const [dismissedPendingCheckout, setDismissedPendingCheckout] = useState(false) + const [welcomeCountry, setWelcomeCountry] = useState('') + const [welcomeVatId, setWelcomeVatId] = useState('') + const [showBillingFields, setShowBillingFields] = useState(false) + const [organizations, setOrganizations] = useState(null) const [orgsLoading, setOrgsLoading] = useState(false) const [switchingOrgId, setSwitchingOrgId] = useState(null) @@ -211,6 +215,13 @@ function WelcomeContent() { setStep(4) return } + + // Show billing fields first if country not yet selected + if (!welcomeCountry) { + setShowBillingFields(true) + return + } + setPlanLoading(true) setPlanError('') try { @@ -220,6 +231,8 @@ function WelcomeContent() { plan_id: intent.planId, interval: intent.interval || 'month', limit: intent.limit ?? 100000, + country: welcomeCountry, + vat_id: welcomeVatId || undefined, }) localStorage.removeItem('pulse_pending_checkout') if (url) { @@ -568,6 +581,52 @@ function WelcomeContent() { {planError && (

{planError}

)} + {showBillingFields && showPendingCheckoutInStep3 && ( +
+
+ + +
+
+ + ) => setWelcomeVatId(e.target.value)} + placeholder="e.g. BE0123456789" + /> +
+
+ )}
{showPendingCheckoutInStep3 ? ( <> @@ -575,9 +634,9 @@ function WelcomeContent() { variant="primary" className="w-full sm:w-auto" onClick={handlePlanContinue} - disabled={planLoading} + disabled={planLoading || (showBillingFields && !welcomeCountry)} > - Continue to checkout + {showBillingFields ? 'Continue to payment' : 'Continue to checkout'}
+ + {/* Checkout Country / VAT Modal */} + {showCheckoutForm && ( +
+
+ +

+ Billing details +

+

+ Select your country to calculate the correct tax rate. +

+ +
+ {/* Country */} +
+ + +
+ + {/* VAT ID */} +
+ + setCheckoutVatId(e.target.value)} + placeholder="e.g. BE0123456789" + className="w-full rounded-lg border border-neutral-700 bg-neutral-800 px-3 py-2.5 text-sm text-white placeholder-neutral-500 focus:border-brand-orange focus:outline-none focus:ring-1 focus:ring-brand-orange transition-colors" + /> +
+ + {/* Actions */} +
+ + +
+
+
+
+ )} ) }