import { useState } from 'react' import { Link, useNavigate } from 'react-router-dom' import { useAuth } from '@/context/AuthContext' import type { IdentifierType } from '@/lib/crypto' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Label } from '@/components/ui/label' const identifierOptions: Array<{ label: string; value: IdentifierType }> = [ { label: 'Email', value: 'email' }, { label: 'Username', value: 'username' }, { label: 'Mobile number', value: 'mobile' }, ] export function LoginPage() { const navigate = useNavigate() const { signIn } = useAuth() const [identifierType, setIdentifierType] = useState('email') const [identifier, setIdentifier] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const [isSubmitting, setIsSubmitting] = useState(false) async function handleSubmit(event: React.FormEvent) { event.preventDefault() setIsSubmitting(true) setError('') try { await signIn({ identifierType, identifier, password }) navigate('/workspace') } catch (err) { setError(err instanceof Error ? err.message : 'Authentication failed.') } finally { setIsSubmitting(false) } } return (
Welcome back Sign in to access your encrypted workspace.
setIdentifier(e.target.value)} placeholder={identifierType === 'mobile' ? '+15555550123' : 'Enter your identifier'} autoComplete={identifierType === 'email' ? 'email' : 'off'} required />
setPassword(e.target.value)} placeholder="Enter your password" autoComplete="current-password" required />
{error &&

{error}

}
Don't have an account?{' '} Sign up
) }