'use client'; import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { AlertTriangle } from 'lucide-react'; import { participantService } from '@/lib/services'; import { Participant } from '@/types'; interface DeleteParticipantModalProps { isOpen: boolean; onClose: () => void; onSuccess: () => void; participant: Participant | null; } export default function DeleteParticipantModal({ isOpen, onClose, onSuccess, participant }: DeleteParticipantModalProps) { const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const handleDelete = async () => { if (!participant) return; setLoading(true); setError(''); try { await participantService.delete(participant.id); onSuccess(); } catch (err: any) { const errorMessage = err?.message || err?.details || 'Erreur lors de la suppression du participant'; setError(`Erreur lors de la suppression du participant: ${errorMessage}`); console.error('Erreur lors de la suppression du participant:', err); } finally { setLoading(false); } }; if (!participant) return null; return ( Supprimer le participant Cette action est irréversible. Le participant sera définitivement supprimé.
{error && (

{error}

)}

Participant à supprimer :

Nom : {participant.first_name} {participant.last_name}

Email : {participant.email}

⚠️ Cette action supprimera également tous les votes associés à ce participant.

); }