"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import { ArrowLeft, MapPin, Clock, Calendar, ExternalLink, Building2 } from "lucide-react";
import { api } from "@/lib/api";
import { Navbar } from "@/components/public/Navbar";
import { Footer } from "@/components/public/Footer";
import { UpcomingEventsCarousel } from "@/components/public/UpcomingEventsCarousel";
import { formatMeetupCivilDate, formatMeetupCivilDateLong, getMeetupStartUtc } from "@/lib/meetupEventTime";
function DateBadge({ dateStr }: { dateStr: string }) {
const civil = formatMeetupCivilDate(dateStr);
const month = civil?.monthShort ?? "—";
const day = civil?.day ?? "--";
return (
{month}
{day}
);
}
function EventSkeleton() {
return (
{[90, 80, 95, 70].map((w, i) => (
))}
);
}
export default function EventDetailClient({ id }: { id: string }) {
const [meetup, setMeetup] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
if (!id) return;
setLoading(true);
api
.getMeetup(id)
.then(setMeetup)
.catch((err) => setError(err.message))
.finally(() => setLoading(false));
}, [id]);
const isPast = meetup
? (() => {
const start = getMeetupStartUtc(meetup.date, meetup.time || "00:00");
return !Number.isNaN(start.getTime()) && start < new Date();
})()
: false;
return (
<>
All Events
{loading &&
}
{error && (
Failed to load event: {error}
)}
{!loading && !error && meetup && (
<>
{meetup.imageId && (
)}
{isPast && (
Past Event
)}
{!isPast && (
Upcoming
)}
{meetup.title}
{meetup.organizer?.slug ? (
Organized by{" "}
{meetup.organizer.name || "Belgian Bitcoin Embassy"}
) : (
Organized by{" "}
{meetup.organizer?.name || "Belgian Bitcoin Embassy"}
)}
{formatMeetupCivilDateLong(meetup.date)}
{meetup.time && (
{meetup.time}
)}
{meetup.location && (
{meetup.location}
)}
{meetup.description && (
)}
{meetup.link && (
Register for this event
)}
>
)}
>
);
}