'use client'; import Layout from '@/components/layout/Layout'; import { memoryData } from '@/utility/constant.utils'; import Link from 'next/link'; import { useSearchParams } from 'next/navigation'; import { useState } from 'react'; import Lightbox from "yet-another-react-lightbox"; import "yet-another-react-lightbox/styles.css"; interface EventData { image: string; title: string; desc?: string; date: string; slug: string; link?: string; gallery?: string[]; } export default function SingleGallery() { const searchParams = useSearchParams(); const slug = searchParams.get('slug'); // Flatten all events into a single array const allEvents: EventData[] = Object.values(memoryData).flat(); // Match event by slug const matchedEvent = allEvents.find(event => event.slug === slug); const galleryImages: string[] = matchedEvent?.gallery || []; const [open, setOpen] = useState(false); const [currentIndex, setCurrentIndex] = useState(0); const handleImageClick = (index: number) => { setCurrentIndex(index); setOpen(true); }; return ( <> {/* Header Section */}

Recent Memories

Home Recent Memories

{matchedEvent?.title || "Photos Gallery"}

{matchedEvent?.desc}

{galleryImages.map((src: string, index: number) => (
handleImageClick(index)} > {`gallery-${index}`}
))} {galleryImages.length === 0 && (

No images found for this event.

)}
setOpen(false)} index={currentIndex} slides={galleryImages.map((src) => ({ src }))} /> ); }