// Events list + event detail function EventsPage() { const { go } = CTSCShell.useNav(); const { data } = CTSCStore.useStore(); const { fmtDate, fedName } = CTSCStore; const [type, setType] = React.useState('All'); const approved = [...data.events].filter(e => e.status === 'Approved').sort((a, b) => a.date.localeCompare(b.date)); const types = ['All', ...Array.from(new Set(approved.map(e => e.type)))]; const list = approved.filter(e => type === 'All' || e.type === type); // group by month const groups = {}; list.forEach(e => { const k = new Date(e.date + 'T00:00:00').toLocaleDateString('en-ZA', { month: 'long', year: 'numeric' }); (groups[k] = groups[k] || []).push(e); }); const typeColor = { Competition: 'var(--navy)', Development: 'var(--ocean)', Festival: 'var(--gold-d)' }; return (
{types.map(t => )}
{Object.entries(groups).map(([month, evs]) => (
{month}
{evs.map(e => { const d = new Date(e.date + 'T00:00:00'); return ( ); })}
))}
); } function EventDetail({ id }) { const { go } = CTSCShell.useNav(); const { data } = CTSCStore.useStore(); const { fmtDate, fedName } = CTSCStore; const { Photo } = CTSCShell; const e = data.events.find(x => x.id === id); if (!e) return ; const d = new Date(e.date + 'T00:00:00'); return (
{e.type}

{e.title}

{e.desc}

); } window.EventsPage = EventsPage; window.EventDetail = EventDetail;