Skip to content

Commit

Permalink
Update handleAddOrganizers
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Jun 24, 2024
1 parent ebbad23 commit c34de55
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions resources/ts/Components/ActivationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit c34de55

Please sign in to comment.