"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import { ArrowLeft, MapPin, Clock, Calendar, ExternalLink } from "lucide-react";
import { api } from "@/lib/api";
import { Navbar } from "@/components/public/Navbar";
import { Footer } from "@/components/public/Footer";
function formatFullDate(dateStr: string) {
const d = new Date(dateStr);
return d.toLocaleString("en-US", {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
});
}
function DateBadge({ dateStr }: { dateStr: string }) {
const d = new Date(dateStr);
const month = d.toLocaleString("en-US", { month: "short" }).toUpperCase();
const day = String(d.getDate());
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 ? new Date(meetup.date) < 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}
{formatFullDate(meetup.date)}
{meetup.time && (
{meetup.time}
)}
{meetup.location && (
{meetup.location}
)}
{meetup.description && (
)}
{meetup.link && (
Register for this event
)}
>
)}
>
);
}