import React, { useState } from 'react'; import axios from 'axios'; import { useHistory } from 'react-router-dom'; const Login = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const history = useHistory(); const handleSubmit = async (e) => { e.preventDefault(); try { const response = await axios.post('/api/auth/login', { email, password }); localStorage.setItem('token', response.data.token); history.push('/dashboard'); } catch (error) { console.error('Error logging in:', error); } }; return (