Evite les doublons dans les emails lors d'import de participants
Set version to 0.2.0 (et affiche le en footer)
This commit is contained in:
@@ -87,6 +87,10 @@ function CampaignParticipantsPageContent() {
|
||||
|
||||
const handleImportParticipants = async (data: any[]) => {
|
||||
try {
|
||||
// Récupérer les participants existants pour vérifier les emails
|
||||
const existingParticipants = await participantService.getByCampaign(campaignId);
|
||||
const existingEmails = new Set(existingParticipants.map(p => p.email.toLowerCase()));
|
||||
|
||||
const participantsToCreate = data.map(row => ({
|
||||
campaign_id: campaignId,
|
||||
first_name: row.Prénom || '',
|
||||
@@ -94,11 +98,24 @@ function CampaignParticipantsPageContent() {
|
||||
email: row.Email || ''
|
||||
}));
|
||||
|
||||
// Créer les participants un par un
|
||||
for (const participant of participantsToCreate) {
|
||||
// Filtrer les participants pour éviter les doublons d'email
|
||||
const newParticipants = participantsToCreate.filter(participant => {
|
||||
const email = participant.email.toLowerCase();
|
||||
return email && !existingEmails.has(email);
|
||||
});
|
||||
|
||||
const skippedCount = participantsToCreate.length - newParticipants.length;
|
||||
|
||||
// Créer les nouveaux participants un par un
|
||||
for (const participant of newParticipants) {
|
||||
await participantService.create(participant);
|
||||
}
|
||||
|
||||
// Afficher un message informatif si des participants ont été ignorés
|
||||
if (skippedCount > 0) {
|
||||
alert(`${skippedCount} participant(s) ignoré(s) car leur email existe déjà dans la campagne.`);
|
||||
}
|
||||
|
||||
loadData();
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de l\'import des participants:', error);
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Badge } from '@/components/ui/badge';
|
||||
|
||||
import AuthGuard from '@/components/AuthGuard';
|
||||
import Footer from '@/components/Footer';
|
||||
import VersionDisplay from '@/components/VersionDisplay';
|
||||
import { FolderOpen, Users, FileText, Plus, BarChart3, Settings, Check, Copy, Mail, Share2 } from 'lucide-react';
|
||||
import StatusSwitch from '@/components/StatusSwitch';
|
||||
import { MarkdownContent } from '@/components/MarkdownContent';
|
||||
@@ -499,6 +500,9 @@ function AdminPageContent() {
|
||||
|
||||
{/* Footer */}
|
||||
<Footer />
|
||||
|
||||
{/* Version Display */}
|
||||
<VersionDisplay />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { PROJECT_CONFIG } from '@/lib/project.config';
|
||||
import Footer from '@/components/Footer';
|
||||
import VersionDisplay from '@/components/VersionDisplay';
|
||||
|
||||
export default function HomePage() {
|
||||
const router = useRouter();
|
||||
@@ -196,6 +197,9 @@ export default function HomePage() {
|
||||
|
||||
{/* Footer */}
|
||||
<Footer variant="home" />
|
||||
|
||||
{/* Version Display */}
|
||||
<VersionDisplay />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user