import React, { useState } from 'react'; import { useAuth } from './context/AuthContext'; import { useNavigate, Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { LogIn, ArrowLeft } from 'lucide-react'; export default function Login() { const { t } = useTranslation(); const { login, startGoogleLogin } = useAuth(); const navigate = useNavigate(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); setError(null); setLoading(true); // Call the login function const result = await login(email, password); setLoading(false); if (result.success) { navigate('/'); } else { setError(result.message); } }; const handleGoogleAuth = async () => { setError(null); const result = await startGoogleLogin(); if (result && !result.success) { setError(result.message); } }; return (
Sign in to your account
{error && (