"use client"; import { useState } from "react"; import { MapPin, Clock, ArrowRight } from "lucide-react"; import Link from "next/link"; import { AddToCalendarButton } from "@/components/public/AddToCalendarDialog"; import { formatMeetupCivilDate } from "@/lib/meetupEventTime"; // Initial number of meetups shown before "Load more". Mobile is enforced via // CSS (3) so there's no SSR/viewport mismatch; desktop shows up to 6. const INITIAL_MOBILE = 3; const INITIAL_DESKTOP = 6; interface MeetupData { id?: string; title: string; date: string; time?: string; location?: string; link?: string; description?: string; organizer?: { name: string; slug?: string }; } interface MeetupsSectionProps { meetups: MeetupData[]; } export function MeetupsSection({ meetups }: MeetupsSectionProps) { // Number of extra batches revealed via "Load more". Each batch adds 3 on // mobile and 6 on desktop, so visible counts are 3*(pages+1) / 6*(pages+1). const [pages, setPages] = useState(0); const mobileVisible = INITIAL_MOBILE * (pages + 1); const desktopVisible = INITIAL_DESKTOP * (pages + 1); // Visibility per card. Enforced with CSS so the server-rendered markup matches // both viewports (desktopVisible >= mobileVisible, so "mobile-only" never occurs). const cardVisibilityClass = (i: number) => { if (i < mobileVisible) return "flex"; if (i < desktopVisible) return "hidden md:flex"; return "hidden"; }; // Show the button only when content is still hidden at the given breakpoint. let loadMoreClass = "hidden"; if (meetups.length > desktopVisible) loadMoreClass = "flex"; else if (meetups.length > mobileVisible) loadMoreClass = "flex md:hidden"; return (

Mark your calendar

Upcoming Meetups

All events
{meetups.length === 0 ? (

No upcoming meetups scheduled. Check back soon.

) : (
{meetups.map((meetup, i) => { const civil = formatMeetupCivilDate(meetup.date); const month = civil?.monthShort ?? "—"; const day = civil?.day ?? "--"; const full = civil?.full ?? ""; const href = meetup.id ? `/events/${meetup.id}` : "#upcoming-meetups"; return (
{month} {day}

{meetup.title}

{full}

{meetup.description && (

{meetup.description}

)}

Organized by{" "} {meetup.organizer?.name || "Belgian Bitcoin Embassy"}

{meetup.location && (

{meetup.location}

)} {meetup.time && (

{meetup.time}

)}
View Details ); })}
)}
All events
); }