"use client"; import { useEffect, useRef, useState } from "react"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { api } from "@/lib/api"; import { getMeetupStartUtc } from "@/lib/meetupEventTime"; import { MeetupCard } from "@/components/public/MeetupCard"; export function UpcomingEventsCarousel({ excludeId }: { excludeId: string }) { const [items, setItems] = useState([]); const scrollerRef = useRef(null); useEffect(() => { api .getMeetups() .then((data: any) => { const list = Array.isArray(data) ? data : []; const now = new Date(); const upcoming = list .filter((m: any) => { if (m.id === excludeId) return false; const start = getMeetupStartUtc(m.date, m.time || "00:00"); if (Number.isNaN(start.getTime())) return false; return start >= now; }) .sort( (a: any, b: any) => getMeetupStartUtc(a.date, a.time || "00:00").getTime() - getMeetupStartUtc(b.date, b.time || "00:00").getTime() ); setItems(upcoming); }) .catch(() => setItems([])); }, [excludeId]); const scrollByDir = (dir: -1 | 1) => { const el = scrollerRef.current; if (!el) return; const delta = Math.min(el.clientWidth * 0.85, 360); el.scrollBy({ left: dir * delta, behavior: "smooth" }); }; if (items.length === 0) return null; return (

More upcoming events

{items.map((m) => (
))}
); }