// Festivals side panel
const FestivalsPanel = ({ festivals, run_date }) => {
const run_date_obj = new Date(run_date);
const fmtName = (col) => col.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
return (
Festivals in Range
{festivals.length}
{festivals.length === 0 ? (
No festivals in next 30 days
) : (
{festivals.map((f, i) => {
const date = new Date(f.date);
const days = Math.round((date - run_date_obj) / 86400000);
const isPast = days < 0;
const is_run_date = days === 0;
return (
-
{date.toLocaleDateString('en-US', { month: 'short' })}
{date.getDate()}
{fmtName(f.name)}
{date.toLocaleDateString('en-US', { weekday: 'long' })}
ยท
{is_run_date ? Today
: isPast ? {Math.abs(days)}d ago
: in {days}d}
);
})}
)}
);
};
window.FestivalsPanel = FestivalsPanel;