Initial microslots implementation
This commit is contained in:
parent
01f29b80c5
commit
277e3a215b
|
@ -15,6 +15,10 @@ export default function useScheduleTable({
|
||||||
const days = Array.from(new Set(filteredSlots.map(slot =>
|
const days = Array.from(new Set(filteredSlots.map(slot =>
|
||||||
getMidnightTimestamp(slot.starts_at)
|
getMidnightTimestamp(slot.starts_at)
|
||||||
))).map(ts => new Date(ts));
|
))).map(ts => new Date(ts));
|
||||||
|
const microslots = Array.from(new Set(filteredSlots.flatMap(slot => [
|
||||||
|
slot.starts_at.getTime(),
|
||||||
|
slot.ends_at.getTime(),
|
||||||
|
]))).map(ts => new Date(ts)).sort();
|
||||||
const filteredHallIds = new Set(filteredSlots.map(slot => slot.hall_id));
|
const filteredHallIds = new Set(filteredSlots.map(slot => slot.hall_id));
|
||||||
const filteredHalls = halls.filter(hall => filteredHallIds.has(hall.id));
|
const filteredHalls = halls.filter(hall => filteredHallIds.has(hall.id));
|
||||||
const hallSlots = Object.fromEntries(filteredHalls.map(hall => [
|
const hallSlots = Object.fromEntries(filteredHalls.map(hall => [
|
||||||
|
@ -31,31 +35,43 @@ export default function useScheduleTable({
|
||||||
},
|
},
|
||||||
...filteredHalls,
|
...filteredHalls,
|
||||||
];
|
];
|
||||||
const rows = days.flatMap(day => [{
|
|
||||||
id: 'header-'.concat(day.getTime().toString()),
|
const rows = microslots.flatMap((date, index, array) => {
|
||||||
|
const isFirst = index === 0;
|
||||||
|
const isLast = index === array.length - 1;
|
||||||
|
const isFirstForTheDay = index > 0 && !isSameDay(date, array[index - 1]);
|
||||||
|
const isLastForTheDay = array?.[index + 1] && !isSameDay(date, array[index + 1]);
|
||||||
|
|
||||||
|
const showHeader = isFirst || isFirstForTheDay;
|
||||||
|
const showSlot = !isLast && !isLastForTheDay;
|
||||||
|
|
||||||
|
return [
|
||||||
|
...showHeader ? [{
|
||||||
|
id: 'header-'.concat(date.getTime().toString()),
|
||||||
cells: [{
|
cells: [{
|
||||||
id: 1,
|
id: 1,
|
||||||
attributes: {
|
attributes: {
|
||||||
colSpan: header.length,
|
colSpan: header.length,
|
||||||
},
|
},
|
||||||
day,
|
day: date,
|
||||||
}]
|
}]
|
||||||
},
|
}] : [],
|
||||||
...filteredSlots.filter(slot => isSameDay(slot.starts_at, day)).map(slot => ({
|
...showSlot ? [{
|
||||||
id: slot.id,
|
id: 'slot-'.concat(date.getTime().toString()),
|
||||||
cells: [{
|
cells: [{
|
||||||
id: 1,
|
id: 1,
|
||||||
day, // TODO replace with slot time
|
day: date, // TODO replace with slot time
|
||||||
}, {
|
}, {
|
||||||
id: 2,
|
id: 2,
|
||||||
attributes: {
|
|
||||||
className: 'schedule-'.concat(slot.event.language).concat(' ').concat(slot.event.track?.css_class),
|
|
||||||
colSpan: 2,
|
|
||||||
},
|
|
||||||
event: slot.event,
|
|
||||||
}],
|
}],
|
||||||
}))
|
// attributes: {
|
||||||
]);
|
// className: 'schedule-'.concat(slot.event.language).concat(' ').concat(slot.event.track?.css_class),
|
||||||
|
// colSpan: 2,
|
||||||
|
// },
|
||||||
|
// event: slot.event,
|
||||||
|
}] : [],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
header,
|
header,
|
||||||
|
|
Loading…
Reference in New Issue