From 2c73ee4d7e754701aa50e51ad8bf876cbe09973d Mon Sep 17 00:00:00 2001 From: Felipe Cardoso Date: Wed, 19 Mar 2025 09:43:58 +0100 Subject: [PATCH] Add purchase link and reservation details to gift list Enhanced the gift list by showing a clickable purchase link icon and added conditional reservation details for reserved or received items using a popover. Simplified and cleaned up related code for better readability and maintainability. --- .../dashboard/events/[slug]/gifts/page.tsx | 136 +++++++++--------- 1 file changed, 71 insertions(+), 65 deletions(-) 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 d48ca76..887059a 100644 --- a/frontend/src/app/(main)/dashboard/events/[slug]/gifts/page.tsx +++ b/frontend/src/app/(main)/dashboard/events/[slug]/gifts/page.tsx @@ -6,16 +6,15 @@ import React, { useEffect, useState } from "react"; import { useParams } from "next/navigation"; import Link from "next/link"; import { - ChevronRight, - Loader2, AlertTriangle, + ChevronRight, + Edit, + ExternalLink, + Loader2, + MoreHorizontal, Plus, Search, - Filter, - Edit, Trash, - MoreHorizontal, - Settings, } from "lucide-react"; import { useEvents } from "@/context/event-context"; import { useGifts } from "@/context/gift-context"; @@ -45,9 +44,14 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; -import { GiftStatus, GiftPriority } from "@/client/types.gen"; +import { GiftPriority, GiftStatus } from "@/client/types.gen"; import { CategoryModal } from "@/components/gifts/category-modal"; import { GiftModal } from "@/components/gifts/gift-modal"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; export default function GiftRegistryPage() { const { slug } = useParams<{ slug: string }>(); @@ -57,6 +61,7 @@ export default function GiftRegistryPage() { items, isLoadingCategories, isLoadingItems, + purchases, error, refetchCategories, refetchItems, @@ -387,19 +392,70 @@ export default function GiftRegistryPage() { const category = categories?.find( (c) => c.id === item.category_id, ); + const canShowReservations = item.status + ? ( + [ + GiftStatus.RESERVED, + GiftStatus.RECEIVED, + ] as GiftStatus[] + ).includes(item.status) + : false; + return ( {category?.name || "Uncategorized"} - + + + {/* Purchase URL clickable icon */} + {item.purchase_url ? ( + + + + ) : ( + + )} {item.name} + {item.quantity_requested || 1} {item.formatted_price || "-"} {getPriorityBadge(item.priority)} - {getStatusBadge(item.status)} + + + {canShowReservations ? ( + + +
+ {getStatusBadge(item.status)} +
+
+ {/**/} + {/* {item.reservations &&*/} + {/* item.reservations.length > 0 ? (*/} + {/*
    */} + {/* {item.reservations.map((res) => (*/} + {/*
  • */} + {/* {res.guest_name}: {res.quantity}*/} + {/*
  • */} + {/* ))}*/} + {/*
*/} + {/* ) : (*/} + {/*

No reservations available.

*/} + {/* )}*/} + {/*
*/} +
+ ) : ( + getStatusBadge(item.status) + )} +
+ @@ -428,68 +484,18 @@ export default function GiftRegistryPage() {
+ + {/* Separate row for description */} + {/*{item.description && (*/} -
- {/* Description - show if available */} - {item.description &&

{item.description}

} - - {/* Status-specific information */} -
- {item.status === GiftStatus.AVAILABLE && ( - <> - {item.store_name && ( - Store: {item.store_name} - )} - - {item.purchase_url && ( - <> - {item.store_name && } - - Shop Link - - - )} - - {!item.store_name && - !item.purchase_url && - item.brand && ( - Brand: {item.brand} - )} - - {!item.store_name && - !item.purchase_url && - !item.brand && ( - - No purchase information available - - )} - - )} - - {item.status === GiftStatus.RESERVED && ( - Reserved - )} - - {item.status === GiftStatus.PURCHASED && ( - Purchased - )} - - {item.status === GiftStatus.RECEIVED && ( - Received - )} -
-
+ {item.description}
+ {/*)}*/}
); })