- améliore l'export/import (format de fichiers en paramètres, amélioration de la robustesse, )
- ajout bouton tout effacer des propositions et participants
This commit is contained in:
@@ -8,6 +8,8 @@ import AddPropositionModal from '@/components/AddPropositionModal';
|
||||
import EditPropositionModal from '@/components/EditPropositionModal';
|
||||
import DeletePropositionModal from '@/components/DeletePropositionModal';
|
||||
import ImportFileModal from '@/components/ImportFileModal';
|
||||
import ExportPropositionsButton from '@/components/ExportPropositionsButton';
|
||||
import ClearAllPropositionsModal from '@/components/ClearAllPropositionsModal';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
|
||||
@@ -29,6 +31,7 @@ function CampaignPropositionsPageContent() {
|
||||
const [showEditModal, setShowEditModal] = useState(false);
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
const [showImportModal, setShowImportModal] = useState(false);
|
||||
const [showClearAllModal, setShowClearAllModal] = useState(false);
|
||||
const [selectedProposition, setSelectedProposition] = useState<Proposition | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -84,11 +87,11 @@ function CampaignPropositionsPageContent() {
|
||||
try {
|
||||
const propositionsToCreate = data.map(row => ({
|
||||
campaign_id: campaignId,
|
||||
title: row.title || '',
|
||||
description: row.description || '',
|
||||
author_first_name: row.author_first_name || 'admin',
|
||||
author_last_name: row.author_last_name || 'admin',
|
||||
author_email: row.author_email || 'admin@example.com'
|
||||
title: row.Titre || '',
|
||||
description: row.Description || '',
|
||||
author_first_name: row.Prénom || 'admin',
|
||||
author_last_name: row.Nom || 'admin',
|
||||
author_email: row.Email || 'admin@example.com'
|
||||
}));
|
||||
|
||||
// Créer les propositions une par une
|
||||
@@ -102,7 +105,15 @@ function CampaignPropositionsPageContent() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleClearAllPropositions = async () => {
|
||||
try {
|
||||
await propositionService.deleteAllByCampaign(campaignId);
|
||||
loadData();
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la suppression des propositions:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const getInitials = (firstName: string, lastName: string) => {
|
||||
return `${firstName.charAt(0)}${lastName.charAt(0)}`.toUpperCase();
|
||||
@@ -171,6 +182,20 @@ function CampaignPropositionsPageContent() {
|
||||
<Upload className="w-4 h-4 mr-2" />
|
||||
Importer
|
||||
</Button>
|
||||
<ExportPropositionsButton
|
||||
propositions={propositions}
|
||||
campaignTitle={campaign.title}
|
||||
/>
|
||||
{propositions.length > 0 && (
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setShowClearAllModal(true)}
|
||||
className="text-red-600 border-red-200 hover:bg-red-50 hover:border-red-300 dark:text-red-400 dark:border-red-800 dark:hover:bg-red-900/20"
|
||||
>
|
||||
<FileText className="w-4 h-4 mr-2" />
|
||||
Tout effacer
|
||||
</Button>
|
||||
)}
|
||||
<Button onClick={() => setShowAddModal(true)} size="lg">
|
||||
✨ Nouvelle proposition
|
||||
</Button>
|
||||
@@ -299,6 +324,14 @@ function CampaignPropositionsPageContent() {
|
||||
type="propositions"
|
||||
campaignTitle={campaign?.title}
|
||||
/>
|
||||
|
||||
<ClearAllPropositionsModal
|
||||
isOpen={showClearAllModal}
|
||||
onClose={() => setShowClearAllModal(false)}
|
||||
onConfirm={handleClearAllPropositions}
|
||||
campaignTitle={campaign?.title}
|
||||
propositionCount={propositions.length}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user