import { useState } from 'react' import { Link, useNavigate, useLocation } from 'react-router-dom' import { useAuthStore } from '@/store/authStore' import { BrandLogo } from '@/components/common/BrandLogo' import { PasswordInput } from '@/components/common/PasswordInput' import { PageMeta } from '@/components/common/PageMeta' 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 || '/' 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 }) const user = useAuthStore.getState().user if (user?.must_change_password) { navigate('/change-password', { replace: true }) } else { navigate(from, { replace: true }) } } catch { // Error is set in the store } } return ( <>
{/* Atmosphere orbs */}

ResolutionFlow

Decision Tree Platform

Sign in to your account

{(error || localError) && (
{localError || error}
)}
setEmail(e.target.value)} className={cn( 'block w-full rounded-[10px] border border-border bg-card px-3 py-2.5', 'text-foreground placeholder:text-muted-foreground', 'focus:border-primary/30 focus:outline-hidden focus:ring-1 focus:ring-primary/20', 'transition-colors' )} placeholder="you@example.com" />
setPassword(e.target.value)} className={cn( 'block w-full rounded-[10px] border border-border bg-card px-3 py-2.5', 'text-foreground placeholder:text-muted-foreground', 'focus:border-primary/30 focus:outline-hidden focus:ring-1 focus:ring-primary/20', 'transition-colors' )} placeholder="••••••••••" />
Forgot password?

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

) } export default LoginPage