import { useState } from 'react'; import { Link } from 'react-router-dom'; import { useAuth } from '../hooks/useAuth'; import { useToast } from '../context/toasts/useToast'; export default function Login() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const { login: handleLogin } = useAuth(); const { addNotification } = useToast(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); try { await handleLogin(email, password); } catch (err) { // Error is handled by the hook (toast shown) const errorMessage = err instanceof Error ? err.message : 'Failed to create card'; addNotification({ type: 'error', title: 'Error Login', message: errorMessage, duration: 5000, }); } }; return (
Don't have an account? Register