import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../contexts/AuthContext'; import toast from 'react-hot-toast'; const Login = () => { const [credentials, setCredentials] = useState({ username: '', password: '' }); const [loading, setLoading] = useState(false); const { login } = useAuth(); const navigate = useNavigate(); const handleSubmit = async (e) => { e.preventDefault(); setLoading(true); try { const result = await login(credentials); if (result.success) { toast.success('Login successful!'); navigate('/'); } else { toast.error(result.error || 'Login failed'); } } catch (error) { toast.error('An error occurred during login'); } finally { setLoading(false); } }; const handleChange = (e) => { setCredentials({ ...credentials, [e.target.name]: e.target.value }); }; return (
Access your file transformation dashboard