'use client' import { useState, useEffect, type FormEvent } from 'react' import { Eye, EyeOff } from 'lucide-react' import { useRouter } from 'next/navigation' import Image from 'next/image' import { Space_Grotesk } from 'next/font/google' import { useAuth } from '@/contexts/auth-context' import { getApiError } from '@/lib/api' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Button } from '@/components/ui/button' const sg = Space_Grotesk({ subsets: ['latin'], weight: ['400', '500', '600', '700'] }) export default function LoginPage() { const { login, user, loading } = useAuth() const router = useRouter() const [identifier, setIdentifier] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState(null) const [submitting, setSubmitting] = useState(false) const [showPassword, setShowPassword] = useState(false) useEffect(() => { if (!loading && user) router.replace('/') }, [user, loading, router]) async function handleSubmit(e: FormEvent) { e.preventDefault() setError(null) setSubmitting(true) try { await login(identifier, password) } catch (err) { setError(getApiError(err)) } finally { setSubmitting(false) } } return (
{/* ── Left panel: image (hidden on mobile, 60% on desktop) ── */}
Distribution warehouse {/* Logo overlay top-left */}
{/* eslint-disable-next-line @next/next/no-img-element */} HexDive HexaDistro
{/* Gradient at bottom */}
{/* Text content pinned to bottom-left */}

Your operations.
Fully in control.

Distribution ERP built for teams that deliver right, every time.

{/* ── Right panel: login card ── */}
{/* Mobile-only logo */}
{/* eslint-disable-next-line @next/next/no-img-element */} HexDive HexaDistro
{/* Logo — desktop only inside card */}
{/* eslint-disable-next-line @next/next/no-img-element */} HexDive HexaDistro
{/* Heading */}

Sign in

Enter your credentials to access your account.

setIdentifier(e.target.value)} className="border-gray-300 bg-white text-gray-900 placeholder:text-gray-400" />
setPassword(e.target.value)} className="border-gray-300 bg-white text-gray-900 placeholder:text-gray-400 pr-10" />
{error && (

{error}

)}
) }