'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { Lock, Send, Loader2 } from 'lucide-react'; export default function LoginPage() { const [step, setStep] = useState<'initial' | 'verify'>('initial'); const [code, setCode] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const router = useRouter(); const sendCode = async () => { setLoading(true); setError(''); try { const res = await fetch('/api/auth/send', { method: 'POST' }); const data = await res.json(); if (!res.ok) throw new Error(data.error || 'Failed to send code'); setStep('verify'); } catch (err: any) { setError(err.message); } finally { setLoading(false); } }; const verifyCode = async () => { setLoading(true); setError(''); try { const res = await fetch('/api/auth/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ code }) }); const data = await res.json(); if (!res.ok) throw new Error(data.error || 'Invalid code'); // Redirect router.push('/'); router.refresh(); } catch (err: any) { setError(err.message); } finally { setLoading(false); } }; return (
Finanzas Personales
Click below to receive a login code via Telegram.
Enter the 6-digit code sent to your Telegram.
setCode(e.target.value)} placeholder="123456" className="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-3 text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500" maxLength={6} />