// Add Profile Modal Component const { useState } = React; const AddProfileModal = ({ onClose, onAdded }) => { const toast = useToast(); const providers = useProviders(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [provider, setProvider] = useState('virgilio'); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); if (!email || !password) { toast('Email e password obbligatori', 'error'); return; } setLoading(true); try { const r = await fetch('/profiles/add', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email_address: email, password, provider }) }); const data = await r.json(); if (r.ok && data.status === 'success') { toast('Profilo aggiunto', 'success'); onAdded(); } else toast(data.detail || 'Errore', 'error'); } catch (e) { toast(`Errore: ${e.message}`, 'error'); } finally { setLoading(false); } }; return (
e.stopPropagation()}>

📧 Aggiungi Profilo

setEmail(e.target.value)} required /> setPassword(e.target.value)} required />
); }; window.AddProfileModal = AddProfileModal;