import { ApiImage } from "@/components/shared/ApiImage"; import { Calendar, MapPin } from "lucide-react"; import { ContactButton } from "@/components/events/ContactButton"; type Event = { id: string; title: string; description?: string; startDate: string; endDate: string; registrationDeadline?: string | null; goLiveAt?: string; price: number; picture?: string; isSoldOut?: boolean; requiresRegistration?: boolean; contactName?: string | null; contactPhone?: string | null; contactEmail?: string | null; location?: string | null; }; import { formatDateTimeRange } from "@/lib/date"; export const EventCard = ({ event }: { event: Event }) => { const dateRange = formatDateTimeRange(event.startDate, event.endDate); return (
{event.picture ? ( ) : (
)}

{event.title}

{dateRange}

{event.location && (

{event.location}

)}

{event.description}

View details {(() => { if (event.requiresRegistration === false) { return ( ); } const now = new Date(); const end = new Date(event.endDate); const deadline = event.registrationDeadline ? new Date(event.registrationDeadline) : null; const goLive = event.goLiveAt ? new Date(event.goLiveAt) : null; const notYetOpen = goLive ? now < goLive : false; const closed = (deadline ? now >= deadline : false) || now >= end; if (notYetOpen) { return ( ); } if (closed) { return ( ); } if (event.isSoldOut) { return ( ); } return ( Register{event.price > 0 ? ` - R${event.price.toFixed(2)}` : ""} ); })()}
); };