From c34de556c02088b5b2ff32c839a1bbb8e47eb41f Mon Sep 17 00:00:00 2001 From: vhande Date: Mon, 24 Jun 2024 13:13:15 +0200 Subject: [PATCH] Update handleAddOrganizers --- resources/ts/Components/ActivationDialog.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/resources/ts/Components/ActivationDialog.tsx b/resources/ts/Components/ActivationDialog.tsx index d217b77e3..5282bfc23 100644 --- a/resources/ts/Components/ActivationDialog.tsx +++ b/resources/ts/Components/ActivationDialog.tsx @@ -192,10 +192,18 @@ export const ActivationDialog = ({ ); const handleAddOrganizers = (organizer: Organizer) => { - let updatedOrganizers = [...organizationForm.data.organizers, organizer]; - updatedOrganizers = [...new Set(updatedOrganizers)]; - organizationForm.setData("organizers", updatedOrganizers); - setIsSearchListVisible(false); + const isDuplicate = + organizationForm.data.organizers.length > 0 && + organizationForm.data.organizers.some( + (existingOrganizer) => existingOrganizer.id === organizer.id + ); + if (!isDuplicate) { + organizationForm.setData("organizers", [ + ...organizationForm.data.organizers, + organizer, + ]); + setIsSearchListVisible(false); + } }; const handleDeleteOrganizer = (deletedOrganizer: string) => {