'use client'; import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import { useAuthStore } from '@/lib/stores/auth-store'; import RoleSelector from '@/components/auth/RoleSelector'; import type { UserRole } from '@/lib/constants/navigation'; import { useTranslation } from '@/lib/hooks/useTranslation'; /** * Login page — Divisi branding + role selector. * * The user picks a role and clicks "Log In" to enter the dashboard. * No real credentials are involved; this is a simulated auth flow. * If the user is already authenticated, redirects to /overview. */ export default function LoginPage() { const router = useRouter(); const login = useAuthStore((s) => s.login); const isAuthenticated = useAuthStore((s) => s.isAuthenticated); const [selectedRole, setSelectedRole] = useState(null); const t = useTranslation(); // Redirect already-authenticated users to the appropriate page useEffect(() => { if (isAuthenticated) { const role = useAuthStore.getState().role; router.replace(role === 'Client_Portal' ? '/portal' : '/overview'); } }, [isAuthenticated, router]); function handleLogin() { if (!selectedRole) return; login(selectedRole); router.push(selectedRole === 'Client_Portal' ? '/portal' : '/overview'); } return (
{/* Branding */}
{/* Logo placeholder */}
D

{t.login.title}

{t.login.subtitle}

{/* Card */}

{t.login.selectRole}

{t.login.selectRoleDesc}

{t.login.copyright}

); }