Move schedule data to JSON file
This commit is contained in:
parent
cb2ad42915
commit
99d04f4b43
5 changed files with 136 additions and 122 deletions
|
@ -1,4 +1,4 @@
|
|||
import { ScheduleEvent, TimeSlot, locations } from "@/app/schedule/events";
|
||||
import { Schedule, ScheduleEvent, ScheduleLocation, TimeSlot } from "@/app/schedule/types";
|
||||
import styles from "./timetable.module.css";
|
||||
|
||||
const oneDayMs = 24 * 60 * 60 * 1000;
|
||||
|
@ -100,7 +100,9 @@ function junctionsFromEdges(edges: Iterable<Edge>) {
|
|||
return keys.map(key => junctions.get(key)!);
|
||||
}
|
||||
|
||||
function* spansFromJunctions(junctions: Iterable<Junction>): Generator<Span> {
|
||||
function* spansFromJunctions(
|
||||
junctions: Iterable<Junction>, locations: ScheduleLocation[]
|
||||
): Generator<Span> {
|
||||
const activeLocations = new Map(
|
||||
locations.map(location => [location.id, new Set<TimeSlot>()])
|
||||
);
|
||||
|
@ -211,7 +213,9 @@ function* cutSpansByHours(span: Span): Generator<Span> {
|
|||
}
|
||||
}
|
||||
|
||||
function tableElementsFromStretches(stretches: Iterable<Stretch>) {
|
||||
function tableElementsFromStretches(
|
||||
stretches: Iterable<Stretch>, locations: ScheduleLocation[]
|
||||
) {
|
||||
type Col = { minutes?: number };
|
||||
type DayHead = { span: number, content?: string }
|
||||
type HourHead = { span: number, content?: string }
|
||||
|
@ -308,17 +312,18 @@ function tableElementsFromStretches(stretches: Iterable<Stretch>) {
|
|||
};
|
||||
}
|
||||
|
||||
export default function Timetable(props: { events: ScheduleEvent[] }) {
|
||||
const junctions = junctionsFromEdges(edgesFromEvents(props.events));
|
||||
const stretches = [...stretchesFromSpans(spansFromJunctions(junctions), oneHourMs * 5)];
|
||||
export default function Timetable(props: { schedule: Schedule }) {
|
||||
const { locations, events } = props.schedule;
|
||||
const junctions = junctionsFromEdges(edgesFromEvents(events));
|
||||
const stretches = [...stretchesFromSpans(spansFromJunctions(junctions, locations), oneHourMs * 5)];
|
||||
const {
|
||||
columnGroups,
|
||||
dayHeaders,
|
||||
hourHeaders,
|
||||
locationRows,
|
||||
} = tableElementsFromStretches(stretches);
|
||||
} = tableElementsFromStretches(stretches, locations);
|
||||
const eventBySlotId = new Map(
|
||||
props.events.flatMap(
|
||||
events.flatMap(
|
||||
event => event.slots.map(slot => [slot.id, event])
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue