'use client'; import { useState } from 'react'; import { motion } from 'framer-motion'; import { HardDrive, Lock, User, LogIn, Shield } from 'lucide-react'; import api from '@/lib/api'; interface LoginPageProps { onSuccess: () => void; } export default function LoginPage({ onSuccess }: LoginPageProps) { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [totpCode, setTotpCode] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const [needs2FA, setNeeds2FA] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(''); setLoading(true); try { const { ok, status, data } = await api.login(username, password, needs2FA ? totpCode : undefined); if (ok) { onSuccess(); } else if (status === 428 && data.totp_required) { setNeeds2FA(true); } else { setError(data.error || 'Login failed'); } } catch { setError('Connection failed. Is the server running?'); } finally { setLoading(false); } } return (
{/* Subtle background gradient orbs */}
{/* Logo & Title */}

Welcome Back

Sign in to access your files

{/* Login Card */}
{!needs2FA ? ( <> ) : (
Two-factor authentication required
)} {error && ( {error} )}
); }