Compare commits

..

No commits in common. "477ea115e8240b5b753e5086b7b04740f84d5588" and "8f3fedcf0703167fb90406b68bb3748fe5ccaa92" have entirely different histories.

View File

@ -1,7 +1,7 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { sorter, toMidnight } from '../utils.js'; import { sorter, toMidnight } from '../utils.js';
import { langs } from '../Schedule/constants.js'; import { langs } from '../Schedule/constants.js';
import { compareAsc, getTime, isSameDay, toDate } from 'date-fns'; import { getTime, isSameDay, toDate } from 'date-fns';
export default function useScheduleTable({ export default function useScheduleTable({
eventTypeId, eventTypeId,
@ -42,36 +42,14 @@ export default function useScheduleTable({
const isFirstForTheDay = index > 0 && !isSameDay(date, array[index - 1]); const isFirstForTheDay = index > 0 && !isSameDay(date, array[index - 1]);
const isLastForTheDay = array?.[index + 1] && !isSameDay(date, array[index + 1]); const isLastForTheDay = array?.[index + 1] && !isSameDay(date, array[index + 1]);
const eventCells = filteredHalls.map(hall => {
const slot = filteredSlots.find(slot =>
slot.hall_id === hall.id &&
compareAsc(slot.starts_at, date) === 0
);
if (!slot) {
return {
id: 'blank-'.concat(hall.id),
};
}
return {
id: 'slot-'.concat(slot.id),
attributes: {
className: 'schedule-'.concat(slot.event.language).concat(' ').concat(slot.event.track?.css_class),
},
event: slot.event,
};
});
const isEmptyRow = !eventCells.find(slot => !!slot.event);
const showHeader = isFirst || isFirstForTheDay; const showHeader = isFirst || isFirstForTheDay;
const showSlot = !isLast && !isLastForTheDay && !isEmptyRow; const showSlot = !isLast && !isLastForTheDay;
return [ return [
...showHeader ? [{ ...showHeader ? [{
id: 'header-'.concat(getTime(date).toString()), id: 'header-'.concat(getTime(date).toString()),
cells: [{ cells: [{
id: 'header', id: 1,
attributes: { attributes: {
colSpan: header.length, colSpan: header.length,
}, },
@ -79,17 +57,21 @@ export default function useScheduleTable({
}], }],
}] : [], }] : [],
...showSlot ? [{ ...showSlot ? [{
id: 'row-'.concat(getTime(date).toString()), id: 'slot-'.concat(getTime(date).toString()),
cells: [ cells: [{
{ id: 1,
id: 'timeslot', timeSlot: {
timeSlot: { start: date,
start: date, end: nextDate,
end: nextDate, }
} }, {
}, id: 2,
...eventCells, // attributes: {
], // className: 'schedule-'.concat(slot.event.language).concat(' ').concat(slot.event.track?.css_class),
// colSpan: 2,
// },
// event: slot.event,
}],
}] : [], }] : [],
]; ];
}); });