import React, { useState } from 'react'; import { Button } from '../../ui/button'; import { Input } from '../../ui/input'; import { Smartphone, QrCode, ArrowLeft, Copy, Download, AlertTriangle } from 'lucide-react'; import { useToast } from '../../../context/ToastContext'; interface TwoFactorSetupProps { onBack: () => void; onComplete: () => void; } export const TwoFactorSetup: React.FC = ({ onBack, onComplete }) => { const { addToast } = useToast(); const [step, setStep] = useState(1); const [method, setMethod] = useState<'totp' | 'sms'>('totp'); const [verificationCode, setVerificationCode] = useState(''); const [backupCodes] = useState(Array.from({length: 10}, () => Math.random().toString(36).substr(2, 8).toUpperCase())); const handleVerify = () => { if (verificationCode.length < 6) { addToast('Invalid code', 'error'); return; } setStep(3); addToast('2FA Verified Successfully', 'success'); }; const copyCodes = () => { navigator.clipboard.writeText(backupCodes.join('\n')); addToast('Backup codes copied to clipboard'); }; const downloadCodes = () => { const element = document.createElement("a"); const file = new Blob([backupCodes.join('\n')], {type: 'text/plain'}); element.href = URL.createObjectURL(file); element.download = "veza-backup-codes.txt"; document.body.appendChild(element); element.click(); addToast('Backup codes downloaded'); }; return (

Enable Two-Factor Authentication

Protect your account with an extra layer of security.

{/* STEP 1: CHOOSE METHOD */} {step === 1 && (
{ setMethod('totp'); setStep(2); }} className="p-6 border border-kodo-steel rounded-xl bg-kodo-ink hover:bg-white/5 cursor-pointer transition-all hover:border-kodo-cyan group" >

Authenticator App

Use Google Authenticator, Authy, or 1Password. (Recommended)

{ setMethod('sms'); setStep(2); }} className="p-6 border border-kodo-steel rounded-xl bg-kodo-ink hover:bg-white/5 cursor-pointer transition-all hover:border-kodo-gold group" >

SMS / Text Message

Receive a code via text message to your phone.

)} {/* STEP 2: CONFIGURE & VERIFY */} {step === 2 && method === 'totp' && (
{/* Mock QR */}
MOCK QR CODE
{/* Decorative pixel pattern simulated */}

Scan this QR code with your authenticator app.

{ navigator.clipboard.writeText("VEZA-SECRET-KEY-123"); addToast("Key copied"); }}> KEY: VEZA-SECRET-KEY-123

Verify Configuration

setVerificationCode(e.target.value.replace(/\D/g,'').slice(0,6))} className="font-mono text-center tracking-widest text-lg" />
)} {step === 2 && method === 'sms' && (

SMS Setup

Enter your phone number to receive a verification code.

Enter Verification Code

setVerificationCode(e.target.value.replace(/\D/g,'').slice(0,6))} className="font-mono text-center tracking-widest text-lg" />
)} {/* STEP 3: BACKUP CODES */} {step === 3 && (

2FA Enabled Successfully

Save these backup codes

If you lose your device, these codes are the only way to access your account. Keep them safe.

{backupCodes.map(code => (
{code}
))}
)}
); };