Compare commits

..

No commits in common. "ff9fbf50a2d090519ee90e387324efd9fba26404" and "b3585ee1cefd412f784389dc21de6b9adc70eedd" have entirely different histories.

2 changed files with 18 additions and 32 deletions

View File

@ -16,11 +16,11 @@ export default function Schedule({
lang,
}) {
const {
speakers: allSpeakers,
tracks: allTracks,
speakers,
tracks,
eventTypes,
halls,
events: allEvents,
events,
slots,
isLoading,
loadingProgress,
@ -32,15 +32,10 @@ export default function Schedule({
const {
header,
rows,
speakers,
tracks,
events,
} = useScheduleTable({
eventTypeId,
speakers: allSpeakers,
tracks: allTracks,
halls,
events: allEvents,
events,
slots,
});
@ -89,7 +84,7 @@ export default function Schedule({
{events.map(event => <section key={event.id} id={'event-'.concat(event.id)}>
<p>
<strong>{event.title}</strong>
{event.participant_users.length > 0 && !isTrackHidden(event.track) && <>
{event.participant_users && !isTrackHidden(event.track) && <>
({event.participant_users.map(speaker => speaker && <Speaker key={speaker.id} {...speaker} />)})
</>}
</p>

View File

@ -5,33 +5,27 @@ import { compareAsc, getTime, isSameDay, toDate } from 'date-fns';
export default function useScheduleTable({
eventTypeId,
speakers: allSpeakers = [],
tracks: allTracks = [],
halls: allHalls = [],
events: allEvents = [],
slots: allSlots = [],
halls = {},
events = {},
slots = {},
}) {
return useMemo(() => {
const events = allEvents.filter(event => eventTypeId > 0 ? event.event_type_id === eventTypeId : true);
const eventIds = events.map(event => event.id);
const speakerIds = events.flatMap(event => event.participant_user_ids);
const speakers = allSpeakers.filter(speaker => speakerIds.includes(speaker.id));
const trackIds = Array.from(new Set(events.map(event => event.track_id)));
const tracks = allTracks.filter(track => trackIds.includes(track.id));
const slots = allSlots.sort(sorter('starts_at')).filter(slot => eventIds.includes(slot.event_id));
const microslots = Array.from(new Set(slots.flatMap(slot => [
const filteredEvents = events.filter(event => eventTypeId > 0 ? event.event_type_id === eventTypeId : true);
const filteredEventIds = filteredEvents.map(event => event.id);
const filteredSlots = slots.sort(sorter('starts_at')).filter(slot => filteredEventIds.includes(slot.event_id));
const microslots = Array.from(new Set(filteredSlots.flatMap(slot => [
getTime(slot.starts_at),
getTime(slot.ends_at),
]))).sort().map(ts => toDate(ts));
const hallIds = new Set(slots.map(slot => slot.hall_id));
const halls = allHalls.filter(hall => hallIds.has(hall.id));
const filteredHallIds = new Set(filteredSlots.map(slot => slot.hall_id));
const filteredHalls = halls.filter(hall => filteredHallIds.has(hall.id));
const skipHallSlots = new Map();
const header = [{
id: 0,
name: Object.fromEntries(Object.keys(langs).map(lang => [lang, ''])),
},
...halls,
...filteredHalls,
];
const rows = microslots.flatMap((date, slotsIndex, slotsArray) => {
@ -42,7 +36,7 @@ export default function useScheduleTable({
const isLastForTheDay = slotsArray?.[slotsIndex + 1] && !isSameDay(date, slotsArray[slotsIndex + 1]);
const rowEvents = new Set();
const eventCells = halls.flatMap((hall, hallIndex, hallsArray) => {
const eventCells = filteredHalls.flatMap((hall, hallIndex, hallsArray) => {
if (skipHallSlots.has(hall.id)) {
const leftToSkip = skipHallSlots.get(hall.id);
@ -56,7 +50,7 @@ export default function useScheduleTable({
return [];
}
const currentTimeSlots = slots.filter(slot => compareAsc(slot.starts_at, date) === 0);
const currentTimeSlots = filteredSlots.filter(slot => compareAsc(slot.starts_at, date) === 0);
const currentHallSlot = currentTimeSlots.find(slot => slot.hall_id === hall.id);
if (!currentHallSlot) {
@ -150,9 +144,6 @@ export default function useScheduleTable({
return {
header,
rows,
tracks,
events,
speakers,
};
}, [eventTypeId, allSpeakers, allTracks, allEvents, allHalls, allSlots]);
}, [eventTypeId, events, halls, slots]);
}