From 353484af2ec58e85424dc7e95a866bc80318434a Mon Sep 17 00:00:00 2001 From: "diana.dolgolyova" Date: Tue, 24 Mar 2026 19:34:02 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20Open=20Day=20schedule=20=E2=80=94?= =?UTF-8?q?=20hall=20selector=20instead=20of=20full=20grid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace wide multi-column hall grid with hall selector tabs + single column time slots. Each hall tab shows class count badge. Scales better as more halls are added. --- src/app/admin/open-day/page.tsx | 124 ++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/src/app/admin/open-day/page.tsx b/src/app/admin/open-day/page.tsx index b402b8b..dfa0f06 100644 --- a/src/app/admin/open-day/page.tsx +++ b/src/app/admin/open-day/page.tsx @@ -292,25 +292,32 @@ function ScheduleGrid({ styles: string[]; onClassesChange: () => void; }) { + const [selectedHall, setSelectedHall] = useState(halls[0] ?? ""); const timeSlots = generateTimeSlots(10, 22); - // Build lookup: hall -> time -> class - const grid = useMemo(() => { - const map: Record> = {}; - for (const hall of halls) map[hall] = {}; + // Build lookup: time -> class for selected hall + const hallClasses = useMemo(() => { + const map: Record = {}; for (const cls of classes) { - if (!map[cls.hall]) map[cls.hall] = {}; - map[cls.hall][cls.startTime] = cls; + if (cls.hall === selectedHall) map[cls.startTime] = cls; } return map; + }, [classes, selectedHall]); + + // Count classes per hall for the tab badges + const hallCounts = useMemo(() => { + const counts: Record = {}; + for (const hall of halls) counts[hall] = 0; + for (const cls of classes) counts[cls.hall] = (counts[cls.hall] || 0) + 1; + return counts; }, [classes, halls]); - async function addClass(hall: string, startTime: string) { + async function addClass(startTime: string) { const endTime = addHour(startTime); await adminFetch("/api/admin/open-day/classes", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ eventId, hall, startTime, endTime, trainer: "—", style: "—" }), + body: JSON.stringify({ eventId, hall: selectedHall, startTime, endTime, trainer: "—", style: "—" }), }); onClassesChange(); } @@ -342,52 +349,61 @@ function ScheduleGrid({ {halls.length === 0 ? (

Нет залов в расписании. Добавьте локации в разделе «Расписание».

) : ( -
- - - - - {halls.map((hall) => ( - - ))} - - - - {timeSlots.map((time) => ( - - - {halls.map((hall) => { - const cls = grid[hall]?.[time]; - return ( - - ); - })} - - ))} - -
Время - {hall} -
{time} - {cls ? ( - - ) : ( - - )} -
-
+ <> + {/* Hall selector */} +
+ {halls.map((hall) => ( + + ))} +
+ + {/* Time slots for selected hall */} +
+ {timeSlots.map((time) => { + const cls = hallClasses[time]; + return ( +
+ {time} +
+ {cls ? ( + + ) : ( + + )} +
+
+ ); + })} +
+ )} );