import { useState } from 'react';
import { auth } from '../firebase/firebase_config';
import { signInWithEmailAndPassword } from 'firebase/auth';
import { Navigate, redirect } from "react-router-dom";
const Login = () => {
const [isLoggedIn, setIsLoggedIn] = useState(false)
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const handleLogin = async () => {
try {
const userCredential = await signInWithEmailAndPassword(auth, email, password);
console.log('User logged in:', userCredential.user);
setIsLoggedIn(true)
} catch (error) {
console.error('Error logging in:', error);
// TODO: Handle error messages or display them to the user.
}
};
return (
isLoggedIn ? (