import { useState } from 'react' import { Link, useNavigate, useLocation } from 'react-router-dom' import { useAuthStore } from '@/store/authStore' import { cn } from '@/lib/utils' export function LoginPage() { const navigate = useNavigate() const location = useLocation() const { login, isLoading, error, clearError } = useAuthStore() const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [localError, setLocalError] = useState('') const from = (location.state as { from?: { pathname: string } })?.from?.pathname || '/trees' const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLocalError('') clearError() if (!email || !password) { setLocalError('Please enter both email and password') return } try { await login({ email, password }) navigate(from, { replace: true }) } catch { // Error is set in the store } } return (

Apoklisis

Sign in to your account

{(error || localError) && (
{localError || error}
)}
setEmail(e.target.value)} className={cn( 'mt-1 block w-full rounded-md border border-input bg-background px-3 py-2', 'text-foreground placeholder:text-muted-foreground', 'focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary' )} placeholder="you@example.com" />
setPassword(e.target.value)} className={cn( 'mt-1 block w-full rounded-md border border-input bg-background px-3 py-2', 'text-foreground placeholder:text-muted-foreground', 'focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary' )} placeholder="••••••••••" />

Don't have an account?{' '} Register

) } export default LoginPage