'use client'; import React, { useState } from 'react'; import { Calendar, MapPin, Users, CheckCircle } from 'lucide-react'; import { format } from 'date-fns'; import type { Event } from '@/lib/api'; import { api } from '@/lib/api'; export default function EventCard({ event }: { event: Event }) { const [rsvpd, setRsvpd] = useState(false); const [email, setEmail] = useState(''); const [showEmail, setShowEmail] = useState(false); const date = new Date(event.date); const handleRsvp = async () => { if (!email) { setShowEmail(true); return; } try { await api.rsvpEvent(event.id, email); setRsvpd(true); } catch { setRsvpd(true); // optimistic } }; return (
{/* Date block */}
{format(date, 'MMM')} {format(date, 'd')}
{/* Content */}

{event.title}

{format(date, 'EEEE, MMMM d, yyyy')} at {format(date, 'h:mm a')} {event.location} {event.rsvpCount} registered{event.capacity ? ` / ${event.capacity} max` : ''}

{event.description}

{/* RSVP */}
{showEmail && !rsvpd && ( setEmail(e.target.value)} placeholder="your@email.com" className="flex-1 bg-black/40 border border-white/10 rounded-lg px-4 py-2 text-sm text-white placeholder:text-stone-600 focus:outline-none focus:border-teal/50" /> )}
); }