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.
This commit is contained in:
@@ -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 className="h-4 w-4 mr-2" /> Edit
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem className="text-red-600">
|
||||
<DropdownMenuItem
|
||||
className="text-red-600"
|
||||
onClick={() => handleDeleteGift(item.id)}
|
||||
>
|
||||
<Trash className="h-4 w-4 mr-2" /> Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
|
||||
Reference in New Issue
Block a user