fix: clear OTP inputs and reset focus on verification failure
All checks were successful
Beta CI/CD Pipeline / build-and-test (push) Successful in 1m30s
Beta CI/CD Pipeline / deploy-beta (push) Successful in 41s

This commit is contained in:
vickytechkey 2026-09-25 17:28:47 +05:30
parent b5c2d137e0
commit de8873859e

View file

@ -218,17 +218,26 @@ export const OnboardingPage: React.FC = () => {
}
setStep1Loading(true);
try {
// Real-time backend OTP verification call
// Real-time backend OTP verification call with strict validation
const res = await api.verifyOtp('phone', enteredOtp);
if (res && res.verified) {
updateOnboarding({ isOtpVerified: true, phone: cleanPhone });
handleNext();
} else {
setStep1Error(res?.error || 'Invalid OTP. Please try again.');
setStep1Error(res?.error || 'Invalid or expired OTP code. Please enter the latest OTP received.');
setStep1Otp(['', '', '', '', '', '']);
setTimeout(() => {
document.getElementById('step1-otp-0')?.focus();
}, 300);
}
} catch (otpErr: any) {
console.warn('OTP verification exception:', otpErr);
setStep1Error(otpErr?.message || 'Invalid OTP. Please try again.');
console.warn('Strict OTP verification failed:', otpErr);
const msg = otpErr?.message || 'Invalid or expired OTP code. Please enter the latest OTP received.';
setStep1Error(msg);
setStep1Otp(['', '', '', '', '', '']);
setTimeout(() => {
document.getElementById('step1-otp-0')?.focus();
}, 300);
} finally {
setStep1Loading(false);
}