import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../components/AuthContext'; export const SuperAdminLogin = () => { const [adminPassword, setAdminPassword] = useState(''); const [adminError, setAdminError] = useState(''); const [showPassword, setShowPassword] = useState(false); const [isLoading, setIsLoading] = useState(false); const navigate = useNavigate(); const { login } = useAuth(); const handleAdminAccess = async (e) => { e.preventDefault(); setIsLoading(true); setAdminError(''); try { const res = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: 'superadmin@gmail.com', password: adminPassword }) }); const data = await res.json(); if (res.ok) { login(data.access_token || data.token, data.refresh_token, data.user); sessionStorage.setItem('superAdminAuth', 'true'); navigate('/super-admin'); } else { setAdminError(data.message || 'Incorrect password'); } } catch { setAdminError('Could not connect to API'); } finally { setIsLoading(false); } }; return (
{/* Background aesthetics */}
LarShield Logo

Global Management

Enter the master password to access LarShield Global Management.

setAdminPassword(e.target.value)} placeholder="Master Password" autoFocus className="w-full border border-outline-variant rounded-xl py-md pl-lg pr-12 focus:ring-2 focus:ring-primary focus:border-primary bg-surface-container text-on-surface text-[15px] outline-none transition-all" />
{adminError &&

{adminError}

}
); };