Welcome back
Access your dashboard and manage tasks effortlessly.
import React, { useState } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import { useAuth } from '../../context/AuthContext'; const Login = () => { const [credentials, setCredentials] = useState({ email: '', password: '' }); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const { login } = useAuth(); const navigate = useNavigate(); const location = useLocation(); const redirectPath = location.state?.from?.pathname ?? '/dashboard'; const handleSubmit = async (event) => { event.preventDefault(); setLoading(true); setError(''); try { await login(credentials); navigate(redirectPath, { replace: true }); } catch (err) { const message = err?.response?.data?.message ?? 'Unable to sign you in. Please try again.'; setError(message); } finally { setLoading(false); } }; return (
Access your dashboard and manage tasks effortlessly.