'use client'; import { useState, memo, useRef } from 'react'; import { User, Shield, ChevronRight, X, Lock } from 'lucide-react'; import { inventoryApi } from '@/lib/api'; import { toast } from 'react-hot-toast'; interface IdentityCheckOverlayProps { show: boolean; users: any[]; onAuthenticated: (user: any) => void; } const IdentityCheckOverlay = memo(({ show, users, onAuthenticated }: IdentityCheckOverlayProps) => { const [selectedUserForLogin, setSelectedUserForLogin] = useState(null); const [isEnterprise, setIsEnterprise] = useState(false); const enterpriseUserRef = useRef(null); const enterprisePassRef = useRef(null); const localPassRef = useRef(null); if (!show) return null; const handleLogin = async () => { let username = ""; let password = ""; if (isEnterprise) { username = enterpriseUserRef.current?.value || ""; password = enterprisePassRef.current?.value || ""; } else if (selectedUserForLogin) { username = selectedUserForLogin.username; password = localPassRef.current?.value || ""; } if (!username) { toast.error("Username is required"); return; } try { const user = await inventoryApi.login({ username, password }); onAuthenticated(user); setSelectedUserForLogin(null); setIsEnterprise(false); } catch (error) { toast.error(isEnterprise ? "Login failed. Check credentials or group membership." : "Invalid password"); } }; const handleSelectUser = async (user: any) => { if (user.username === 'Admin' || user.id > 1) { setSelectedUserForLogin(user); return; } onAuthenticated(user); }; return (
{/* Subtle accent light */}

Protocol Access

Select operator profile to initialize

{!selectedUserForLogin && !isEnterprise ? ( <> {users.map(user => ( ))}
) : isEnterprise ? (

LDAP Authentication

e.key === 'Enter' && handleLogin()} className="w-full bg-background/50 border border-slate-800/80 focus:border-primary/50 focus:bg-background rounded-[1.25rem] py-4.5 pl-14 pr-5 text-sm text-slate-100 focus:outline-none transition-all placeholder:text-slate-700 font-mono" placeholder="••••••••" />
) : (

Active Profile

{selectedUserForLogin.username}

e.key === 'Enter' && handleLogin()} className="w-full bg-background/50 border border-slate-800/80 focus:border-primary/50 focus:bg-background rounded-[1.25rem] py-4.5 pl-14 pr-5 text-sm text-slate-100 focus:outline-none transition-all placeholder:text-slate-700 font-mono" placeholder="KEY-PHRASE" />
)}
{users.length === 0 && (
Synchronizing User Tokens...
)}
); }); export default IdentityCheckOverlay;