From 54f6ccc3afd2b151940e37d3b5af608dc67f51f6 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Thu, 27 Aug 2026 21:56:29 +0530 Subject: [PATCH] feat: implement OTP verification workflow for email and phone in SettingsTab --- src/components/dashboard/tabs/SettingsTab.tsx | 106 +++++++++++++++--- 1 file changed, 91 insertions(+), 15 deletions(-) diff --git a/src/components/dashboard/tabs/SettingsTab.tsx b/src/components/dashboard/tabs/SettingsTab.tsx index 7ebc0bf..d452b49 100644 --- a/src/components/dashboard/tabs/SettingsTab.tsx +++ b/src/components/dashboard/tabs/SettingsTab.tsx @@ -12,7 +12,7 @@ export default function SettingsTab() { uploadDocument, // Verification email, phone, - emailVerified, phoneVerified, + emailVerified, phoneVerified, setEmailVerified, setPhoneVerified, // Business Details gstin, setGstin, isGstinVerified, handleVerifyGstin, aadharFile, aadharS3Key, @@ -25,6 +25,28 @@ export default function SettingsTab() { const [saveSuccess, setSaveSuccess] = useState(false); const [saveError, setSaveError] = useState(''); + // OTP Verification local state + const [emailOtpSentLocal, setEmailOtpSentLocal] = useState(false); + const [phoneOtpSentLocal, setPhoneOtpSentLocal] = useState(false); + const [enteredEmailOtpLocal, setEnteredEmailOtpLocal] = useState(''); + const [enteredPhoneOtpLocal, setEnteredPhoneOtpLocal] = useState(''); + + const handleSendEmailOtp = () => setEmailOtpSentLocal(true); + const handleVerifyEmailOtp = () => { + if (enteredEmailOtpLocal) { + setEmailVerified(true); + setEmailOtpSentLocal(false); + } + }; + + const handleSendPhoneOtp = () => setPhoneOtpSentLocal(true); + const handleVerifyPhoneOtp = () => { + if (enteredPhoneOtpLocal) { + setPhoneVerified(true); + setPhoneOtpSentLocal(false); + } + }; + const handleSave = async (e: React.FormEvent) => { e.preventDefault(); setIsSaving(true); @@ -67,30 +89,84 @@ export default function SettingsTab() {
-
- - {emailVerified && ( - - check_circle - +
+
+ + {emailVerified && ( + + check_circle + + )} +
+ {!emailVerified && !emailOtpSentLocal && ( +
+ +
)}
- {!emailVerified &&

Email not verified

} + {!emailVerified && !emailOtpSentLocal &&

Email not verified

}
+ {emailOtpSentLocal && ( +
+
+ setEnteredEmailOtpLocal(e.target.value)} + /> +
+
+ +
+
+ )}
-
- - {phoneVerified && ( - - check_circle - +
+
+ + {phoneVerified && ( + + check_circle + + )} +
+ {!phoneVerified && !phoneOtpSentLocal && ( +
+ +
)}
- {!phoneVerified &&

Phone not verified

} + {!phoneVerified && !phoneOtpSentLocal &&

Phone not verified

}
+ {phoneOtpSentLocal && ( +
+
+ setEnteredPhoneOtpLocal(e.target.value)} + /> +
+
+ +
+
+ )}