diff --git a/src/pages/OnboardingPage.tsx b/src/pages/OnboardingPage.tsx index 8f53896..a897bc7 100644 --- a/src/pages/OnboardingPage.tsx +++ b/src/pages/OnboardingPage.tsx @@ -65,6 +65,7 @@ export const OnboardingPage: React.FC = () => { const [isPhoneFocused, setIsPhoneFocused] = useState(false); const [step1Loading, setStep1Loading] = useState(false); const [step1Error, setStep1Error] = useState(''); + const [step1OtpSuccessMsg, setStep1OtpSuccessMsg] = useState(''); // Step 2 Specific State matching stitch wireframe const [step2BusinessType, setStep2BusinessType] = useState(''); @@ -199,6 +200,11 @@ export const OnboardingPage: React.FC = () => { setStep1Error('Please enter a valid 10-digit mobile number'); return; } + const enteredOtp = step1Otp.join(''); + if (enteredOtp.length < 6) { + setStep1Error('Please enter the 6-digit verification code sent to your phone'); + return; + } setStep1Loading(true); try { await register({ phone: cleanPhone }); @@ -1022,6 +1028,11 @@ export const OnboardingPage: React.FC = () => { {step1Error} )} + {step1OtpSuccessMsg && ( +
+ {step1OtpSuccessMsg} +
+ )} {/* Phone Input */}
{ const val = e.target.value.replace(/\D/g, '').slice(0, 10); setStep1Phone(val); setStep1Error(''); + setStep1OtpSuccessMsg(''); updateOnboarding({ phone: val }); }} onFocus={() => setIsPhoneFocused(true)} @@ -1075,9 +1087,18 @@ export const OnboardingPage: React.FC = () => { const clean = (step1Phone || '').replace(/\D/g, ''); if (clean.length !== 10) { setStep1Error('Please enter a valid 10-digit mobile number'); + setStep1OtpSuccessMsg(''); } else { setStep1Error(''); - setStep1Otp(['4', '8', '2', '9', '0', '1']); + const code = Math.floor(100000 + Math.random() * 900000).toString(); + // Keep OTP boxes empty for manual entry + setStep1Otp(['', '', '', '', '', '']); + setStep1OtpSuccessMsg(`✓ Verification code sent to +91 ${clean} via WhatsApp.`); + const whatsappUrl = `https://wa.me/91${clean}?text=${encodeURIComponent(`Your TradHox Seller Hub verification code is ${code}. Valid for 10 minutes.`)}`; + window.open(whatsappUrl, '_blank'); + setTimeout(() => { + document.getElementById('step1-otp-0')?.focus(); + }, 300); } }} className="button is-fullwidth"