import React, { useState } from 'react'; import { useAuth } from '../contexts/AuthContext'; import { useNavigate } from 'react-router-dom'; const Login: React.FC = () => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const { login } = useAuth(); const navigate = useNavigate(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setIsLoading(true); try { await login(username, password); navigate('/dashboard'); } catch (err: any) { setError(err.response?.data?.detail || 'Invalid username or password'); } finally { setIsLoading(false); } }; return (
Welcome back! Please sign in.
Default password: password123