import { useState, FormEvent } from 'react'; import { useAuth } from '../hooks/useAuth'; import { sendAuthResponse } from '../utils/iframe'; export function LoginForm(): JSX.Element { const { keyPair, isLoading, createAuthResponse } = useAuth(); const [isAuthenticating, setIsAuthenticating] = useState(false); const handleSubmit = (e: FormEvent): void => { e.preventDefault(); void (async (): Promise => { if (keyPair === null || isLoading) { return; } setIsAuthenticating(true); try { const response = createAuthResponse(); if (response !== null) { sendAuthResponse(response); } else { console.error('Failed to create auth response'); } } catch (error) { console.error('Authentication error:', error); } finally { setIsAuthenticating(false); } })(); }; if (isLoading) { return (
Chargement...
); } return (
); }