import React, { useState, useEffect } from "react" import { useAuth } from "../services/authService" export default function SignInPage() { const [username, setUsername] = useState("") const [password, setPassword] = useState("") const [error, setError] = useState("") const { login, isAuthenticated, isLoading } = useAuth() useEffect(() => { // Redirect if already authenticated if (isAuthenticated) { window.location.href = "/" } }, [isAuthenticated]) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") const result = await login({ username, password }) if (!result.success) { setError(result.error || "Invalid credentials") } else { // Redirect to main app window.location.href = "/" } } // Show loading spinner if checking auth state if (isLoading) { return (
Loading...
) } return (

ACE UI Login

Enter your credentials to access the dashboard

setUsername(e.target.value)} />
setPassword(e.target.value)} />
{error && (
{error}
)}
) }