import * as React from 'react'; import { useNavigate } from 'react-router-dom'; import { Button } from '@/components/ui/button'; import { useAuth } from '@/lib/auth'; /** * Login page — accepts API Base URL, Client ID, and Client Secret. * Validates credentials against the AgentIdP token endpoint before persisting. */ export default function Login(): React.JSX.Element { const { login } = useAuth(); const navigate = useNavigate(); const [baseUrl, setBaseUrl] = React.useState(window.location.origin); const [clientId, setClientId] = React.useState(''); const [clientSecret, setClientSecret] = React.useState(''); const [loading, setLoading] = React.useState(false); const [error, setError] = React.useState(null); const handleSubmit = React.useCallback( async (e: React.FormEvent): Promise => { e.preventDefault(); setError(null); setLoading(true); try { const success = await login({ baseUrl: baseUrl.trim(), clientId: clientId.trim(), clientSecret }); if (success) { navigate('/dashboard/agents', { replace: true }); } else { setError('Invalid credentials. Please check your Client ID and secret.'); setClientSecret(''); } } finally { setLoading(false); } }, [login, navigate, baseUrl, clientId, clientSecret], ); return (

SentryAgent.ai

AgentIdP Dashboard — Sign In

{ void handleSubmit(e); }} className="space-y-5">
{ setBaseUrl(e.target.value); }} className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2 text-sm shadow-sm focus:border-brand-500 focus:outline-none focus:ring-1 focus:ring-brand-500" placeholder="https://api.example.com" />
{ setClientId(e.target.value); }} className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2 text-sm shadow-sm focus:border-brand-500 focus:outline-none focus:ring-1 focus:ring-brand-500" placeholder="agent-uuid" autoComplete="username" />
{ setClientSecret(e.target.value); }} className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2 text-sm shadow-sm focus:border-brand-500 focus:outline-none focus:ring-1 focus:ring-brand-500" autoComplete="current-password" />
{error && (

{error}

)}
); }