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:
@@ -27,17 +27,17 @@ export function McRegistrationsTab({ filter }: { filter: BookingFilter }) {
|
||||
const dates: Record<string, string> = {};
|
||||
const mcItems = mcData.items || [];
|
||||
for (const mc of mcItems) {
|
||||
const latestSlot = mc.slots?.reduce((latest, s) => s.date > latest ? s.date : latest, "");
|
||||
if (latestSlot) dates[mc.title] = latestSlot;
|
||||
const earliestSlot = mc.slots?.reduce((min, s) => s.date < min ? s.date : min, mc.slots[0]?.date ?? "");
|
||||
if (earliestSlot) dates[mc.title] = earliestSlot;
|
||||
}
|
||||
const regTitles = new Set(regData.map((r) => r.masterClassTitle));
|
||||
for (const regTitle of regTitles) {
|
||||
if (dates[regTitle]) continue;
|
||||
for (const mc of mcItems) {
|
||||
const latestSlot = mc.slots?.reduce((latest, s) => s.date > latest ? s.date : latest, "");
|
||||
if (!latestSlot) continue;
|
||||
const earliestSlot = mc.slots?.reduce((min, s) => s.date < min ? s.date : min, mc.slots[0]?.date ?? "");
|
||||
if (!earliestSlot) continue;
|
||||
if (regTitle.toLowerCase().includes(mc.title.toLowerCase()) || mc.title.toLowerCase().includes(regTitle.toLowerCase())) {
|
||||
dates[regTitle] = latestSlot;
|
||||
dates[regTitle] = earliestSlot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user