"use client"; import { useState } from "react"; import { api } from "@/trpc/react"; import { Empty, EmptyDescription, EmptyHeader, EmptyTitle, } from "@/components/ui/empty"; import { Skeleton } from "@/components/ui/skeleton"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; export function GuestGallery({ slug }: { slug: string }) { const gallery = api.event.gallery.useQuery(slug); const [active, setActive] = useState(null); if (gallery.isLoading) { return (
{Array.from({ length: 6 }).map((_, index) => ( ))}
); } const photos = gallery.data ?? []; const selected = photos.find((photo) => photo.id === active); if (photos.length === 0) { return ( No photos in the gallery yet Photos will appear here after the event people release the gallery. ); } return ( <>
{photos.map((photo, index) => photo.thumbUrl || photo.displayUrl ? ( ) : null, )}
!open && setActive(null)}> {selected?.contributorName ?? "Shared by a guest"} Full-size event photo {selected?.displayUrl || selected?.thumbUrl ? ( // eslint-disable-next-line @next/next/no-img-element ) : null} ); }