? Updated Workflow Voting
? Updated Workflow Voting
Working:
━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 VoterLogin.tsx – Phone Number Input and Trigger OTP Brief: UI for
entering phone number and requesting OTP.
function VoterLogin() { const [phone, setPhone] = useState(''); const navigate =
useNavigate();
const sendOtp = async () => { const res = await fetch('/api/send-otp', { method:
'POST', headers: { 'Content-Type': 'application/json' }, body:
JSON.stringify({ phone }), });
if (res.ok) {
navigate('/verify', { state: { phone } });
} else {
alert('Failed to send OTP');
}
};
return ( <input type="tel" placeholder="Enter phone number" onChange={e =>
setPhone(e.target.value)} /> Send OTP ); }
Explanation:
User enters phone number.
Triggers sendOtp() to call backend.
POSTs phone number to /api/send-otp.
Navigates to /verify if successful.
Else shows alert.
Uses React Router's useNavigate.
Working:
━━━━━━━━━━━━━━━━━━━━━━━━━━━
Working:
━━━━━━━━━━━━━━━━━━━━━━━━━━━
Working:
━━━━━━━━━━━━━━━━━━━━━━━━━━━
TWILIO_SID=ACxxxxxxxxxxxx TWILIO_TOKEN=your_token
TWILIO_PHONE=+1234567890
Explanation:
Securely stores Twilio credentials.
Used by Twilio client in backend.
Should never be committed to Git.
Loaded using dotenv package.
Keeps API secrets out of source code.