From 472a0b7834997550e2697026420d321b4d209528 Mon Sep 17 00:00:00 2001 From: Felipe Cardoso Date: Wed, 19 Mar 2025 08:23:26 +0100 Subject: [PATCH] Add delete functionality for gifts in the dashboard Introduced `handleDeleteGift` to delete a gift and refetch items after deletion. Connected the delete action to the dropdown menu, enabling users to remove gifts from the UI seamlessly. This enhances gift management capabilities on the dashboard. --- .../app/(main)/dashboard/events/[slug]/gifts/page.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/(main)/dashboard/events/[slug]/gifts/page.tsx b/frontend/src/app/(main)/dashboard/events/[slug]/gifts/page.tsx index d943a34..d48ca76 100644 --- a/frontend/src/app/(main)/dashboard/events/[slug]/gifts/page.tsx +++ b/frontend/src/app/(main)/dashboard/events/[slug]/gifts/page.tsx @@ -62,6 +62,7 @@ export default function GiftRegistryPage() { refetchItems, currentEventId, setCurrentEventId, + deleteItem, } = useGifts(); // State for modals @@ -188,6 +189,11 @@ export default function GiftRegistryPage() { setIsAddGiftModalOpen(true); }; + const handleDeleteGift = async (id: string) => { + await deleteItem(id); + await refetchItems(undefined, event?.id); + }; + const handleEditGift = (giftId: string) => { setSelectedGiftId(giftId); setIsEditGiftModalOpen(true); @@ -412,7 +418,10 @@ export default function GiftRegistryPage() { Edit - + handleDeleteGift(item.id)} + > Delete