// Profiles View Component const { useState, useEffect } = React; const ProfilesView = () => { const toast = useToast(); const [profiles, setProfiles] = useState([]); const [showAdd, setShowAdd] = useState(false); const [selectedProfile, setSelectedProfile] = useState(null); const [loading, setLoading] = useState(true); const [refreshing, setRefreshing] = useState(false); const [confirmRemove, setConfirmRemove] = useState(null); // profileId useEffect(() => { const fetchProfiles = () => { fetch('/profiles').then(r => r.json()).then(data => { if (data.status === 'success') setProfiles(data.profiles || []); }).catch(console.error).finally(() => setLoading(false)); }; fetchProfiles(); const interval = setInterval(fetchProfiles, 5000); return () => clearInterval(interval); }, []); const handleRefresh = async (id) => { try { await fetch(`/profiles/${id}/refresh`, { method: 'POST' }); toast('Aggiornamento in corso...', 'info'); } catch (e) { toast('Errore aggiornamento', 'error'); } }; const handleRefreshAll = async () => { setRefreshing(true); try { await fetch('/profiles/refresh-all', { method: 'POST' }); toast('Tutti i profili aggiornati', 'success'); } catch (e) { toast('Errore aggiornamento', 'error'); } finally { setRefreshing(false); } }; const handleRemove = (id) => { setConfirmRemove(id); }; const executeRemove = async () => { if (!confirmRemove) return; try { const r = await fetch(`/profiles/${confirmRemove}`, { method: 'DELETE' }); if (r.ok) { toast('Profilo rimosso', 'success'); setProfiles(p => p.filter(x => x.id !== confirmRemove)); } setConfirmRemove(null); } catch (e) { toast('Errore rimozione', 'error'); setConfirmRemove(null); } }; return (
Clicca su un profilo per vedere le email ricevute
I profili appariranno automaticamente dopo la registrazione