Compare commits
No commits in common. "ff9fbf50a2d090519ee90e387324efd9fba26404" and "b3585ee1cefd412f784389dc21de6b9adc70eedd" have entirely different histories.
ff9fbf50a2
...
b3585ee1ce
|
@ -16,11 +16,11 @@ export default function Schedule({
|
||||||
lang,
|
lang,
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
speakers: allSpeakers,
|
speakers,
|
||||||
tracks: allTracks,
|
tracks,
|
||||||
eventTypes,
|
eventTypes,
|
||||||
halls,
|
halls,
|
||||||
events: allEvents,
|
events,
|
||||||
slots,
|
slots,
|
||||||
isLoading,
|
isLoading,
|
||||||
loadingProgress,
|
loadingProgress,
|
||||||
|
@ -32,15 +32,10 @@ export default function Schedule({
|
||||||
const {
|
const {
|
||||||
header,
|
header,
|
||||||
rows,
|
rows,
|
||||||
speakers,
|
|
||||||
tracks,
|
|
||||||
events,
|
|
||||||
} = useScheduleTable({
|
} = useScheduleTable({
|
||||||
eventTypeId,
|
eventTypeId,
|
||||||
speakers: allSpeakers,
|
|
||||||
tracks: allTracks,
|
|
||||||
halls,
|
halls,
|
||||||
events: allEvents,
|
events,
|
||||||
slots,
|
slots,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,7 +84,7 @@ export default function Schedule({
|
||||||
{events.map(event => <section key={event.id} id={'event-'.concat(event.id)}>
|
{events.map(event => <section key={event.id} id={'event-'.concat(event.id)}>
|
||||||
<p>
|
<p>
|
||||||
<strong>{event.title}</strong>
|
<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} />)})
|
({event.participant_users.map(speaker => speaker && <Speaker key={speaker.id} {...speaker} />)})
|
||||||
</>}
|
</>}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -5,33 +5,27 @@ import { compareAsc, getTime, isSameDay, toDate } from 'date-fns';
|
||||||
|
|
||||||
export default function useScheduleTable({
|
export default function useScheduleTable({
|
||||||
eventTypeId,
|
eventTypeId,
|
||||||
speakers: allSpeakers = [],
|
halls = {},
|
||||||
tracks: allTracks = [],
|
events = {},
|
||||||
halls: allHalls = [],
|
slots = {},
|
||||||
events: allEvents = [],
|
|
||||||
slots: allSlots = [],
|
|
||||||
}) {
|
}) {
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
const events = allEvents.filter(event => eventTypeId > 0 ? event.event_type_id === eventTypeId : true);
|
const filteredEvents = events.filter(event => eventTypeId > 0 ? event.event_type_id === eventTypeId : true);
|
||||||
const eventIds = events.map(event => event.id);
|
const filteredEventIds = filteredEvents.map(event => event.id);
|
||||||
const speakerIds = events.flatMap(event => event.participant_user_ids);
|
const filteredSlots = slots.sort(sorter('starts_at')).filter(slot => filteredEventIds.includes(slot.event_id));
|
||||||
const speakers = allSpeakers.filter(speaker => speakerIds.includes(speaker.id));
|
const microslots = Array.from(new Set(filteredSlots.flatMap(slot => [
|
||||||
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 => [
|
|
||||||
getTime(slot.starts_at),
|
getTime(slot.starts_at),
|
||||||
getTime(slot.ends_at),
|
getTime(slot.ends_at),
|
||||||
]))).sort().map(ts => toDate(ts));
|
]))).sort().map(ts => toDate(ts));
|
||||||
const hallIds = new Set(slots.map(slot => slot.hall_id));
|
const filteredHallIds = new Set(filteredSlots.map(slot => slot.hall_id));
|
||||||
const halls = allHalls.filter(hall => hallIds.has(hall.id));
|
const filteredHalls = halls.filter(hall => filteredHallIds.has(hall.id));
|
||||||
const skipHallSlots = new Map();
|
const skipHallSlots = new Map();
|
||||||
|
|
||||||
const header = [{
|
const header = [{
|
||||||
id: 0,
|
id: 0,
|
||||||
name: Object.fromEntries(Object.keys(langs).map(lang => [lang, ''])),
|
name: Object.fromEntries(Object.keys(langs).map(lang => [lang, ''])),
|
||||||
},
|
},
|
||||||
...halls,
|
...filteredHalls,
|
||||||
];
|
];
|
||||||
|
|
||||||
const rows = microslots.flatMap((date, slotsIndex, slotsArray) => {
|
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 isLastForTheDay = slotsArray?.[slotsIndex + 1] && !isSameDay(date, slotsArray[slotsIndex + 1]);
|
||||||
const rowEvents = new Set();
|
const rowEvents = new Set();
|
||||||
|
|
||||||
const eventCells = halls.flatMap((hall, hallIndex, hallsArray) => {
|
const eventCells = filteredHalls.flatMap((hall, hallIndex, hallsArray) => {
|
||||||
if (skipHallSlots.has(hall.id)) {
|
if (skipHallSlots.has(hall.id)) {
|
||||||
const leftToSkip = skipHallSlots.get(hall.id);
|
const leftToSkip = skipHallSlots.get(hall.id);
|
||||||
|
|
||||||
|
@ -56,7 +50,7 @@ export default function useScheduleTable({
|
||||||
return [];
|
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);
|
const currentHallSlot = currentTimeSlots.find(slot => slot.hall_id === hall.id);
|
||||||
|
|
||||||
if (!currentHallSlot) {
|
if (!currentHallSlot) {
|
||||||
|
@ -150,9 +144,6 @@ export default function useScheduleTable({
|
||||||
return {
|
return {
|
||||||
header,
|
header,
|
||||||
rows,
|
rows,
|
||||||
tracks,
|
|
||||||
events,
|
|
||||||
speakers,
|
|
||||||
};
|
};
|
||||||
}, [eventTypeId, allSpeakers, allTracks, allEvents, allHalls, allSlots]);
|
}, [eventTypeId, events, halls, slots]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue