fix: MC series uses earliest slot date for registration cutoff

Multi-session master classes are a series — once the first session
passes, the group has started and registration closes. Changed all
MC date logic from "latest slot" / "any future slot" to "earliest slot":

- DashboardSummary: upcoming = earliest slot >= today
- McRegistrationsTab: archive = earliest slot < today
- AddBookingModal: only show MCs where earliest slot >= today
- Public MasterClasses: isUpcoming checks earliest slot
This commit is contained in:
2026-03-24 17:35:31 +03:00
parent b48cc040e1
commit 18c11d0611
4 changed files with 24 additions and 18 deletions

View File

@@ -42,10 +42,13 @@ export function AddBookingModal({
adminFetch("/api/admin/sections/masterClasses").then((r) => r.json()).then((data: { items?: { title: string; slots: { date: string }[] }[] }) => {
const today = new Date().toISOString().split("T")[0];
const upcoming = (data.items || [])
.filter((mc) => mc.slots?.some((s) => s.date >= today))
.filter((mc) => {
const earliest = mc.slots?.reduce((min, s) => s.date < min ? s.date : min, mc.slots[0]?.date ?? "");
return earliest && earliest >= today;
})
.map((mc) => ({
title: mc.title,
date: mc.slots.reduce((latest, s) => s.date > latest ? s.date : latest, ""),
date: mc.slots.reduce((min, s) => s.date < min ? s.date : min, mc.slots[0]?.date ?? ""),
}));
setMcOptions(upcoming);
if (upcoming.length === 0 && tab === "events") setEventType("open-day");