import { Navbar } from "@/components/layout/Navbar"; import { Footer } from "@/components/layout/Footer"; import { EventCard } from "@/components/events/EventCard"; import { apiFetch } from "@/lib/api"; import { Calendar, CalendarX } from "lucide-react"; export const revalidate = 60; type Event = { id: string; title: string; description?: string; startDate: string; endDate: string; registrationDeadline?: string | null; goLiveAt?: string; price: number; picture?: string; isSoldOut?: boolean; cashupStatus?: string; }; export default async function EventsPage() { const events = await apiFetch("/api/events", { nextOptions: { next: { revalidate: 60 } } }); const now = Date.now(); const upcoming = (events || []).filter(e => { if (e.cashupStatus === "closed") return false; const t = new Date(e.startDate).getTime(); return !isNaN(t) && t > now; }); const sorted = [...upcoming].sort((a, b) => new Date(a.startDate).getTime() - new Date(b.startDate).getTime()); return (

All Events

{sorted.length} upcoming event{sorted.length === 1 ? "" : "s"}

{sorted.length === 0 ? (

No events available right now — check back soon.

) : (
{sorted.map((event) => ( ) )}
)}
); }