Compare commits
6 Commits
4774dcda11
...
f6c71b9897
Author | SHA1 | Date |
---|---|---|
Vencislav Atanasov | f6c71b9897 | |
Vencislav Atanasov | 316e75c3f7 | |
Vencislav Atanasov | 89d6ad71d9 | |
Vencislav Atanasov | 2afc4f2b6a | |
Vencislav Atanasov | 1dd3ff9292 | |
Vencislav Atanasov | 2e83ef89b4 |
|
@ -1,11 +1,18 @@
|
||||||
import PropTypes from 'prop-types';
|
import { isTrackHidden } from './utils.js';
|
||||||
|
import Speaker from './Speaker.jsx';
|
||||||
|
import FeedbackLink from './FeedbackLink.jsx';
|
||||||
|
|
||||||
export default function Event({
|
export default function Event(event) {
|
||||||
title,
|
return (<>
|
||||||
}) {
|
<a href={'#lecture-'.concat(event.id)}>{event.title}</a>
|
||||||
return (<strong>{title}</strong>);
|
<br />
|
||||||
|
{event.participant_users && !isTrackHidden(event.track) && <>
|
||||||
|
{event.participant_users.map(speaker => speaker && <Speaker key={speaker.id} {...speaker} />)}
|
||||||
|
</>}
|
||||||
|
<p>
|
||||||
|
<i>
|
||||||
|
<FeedbackLink {...event} />
|
||||||
|
</i>
|
||||||
|
</p>
|
||||||
|
</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
Event.propTypes = {
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export default function FeedbackLink(event) {
|
||||||
|
return (<a href={event.feedback_url}>Submit feedback</a>);
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import Event from './Event.jsx';
|
||||||
import defaultSpeaker from '../assets/default-speaker.png';
|
import defaultSpeaker from '../assets/default-speaker.png';
|
||||||
import './Schedule.scss';
|
import './Schedule.scss';
|
||||||
import { langs } from './constants.js';
|
import { langs } from './constants.js';
|
||||||
|
import Speaker from './Speaker.jsx';
|
||||||
|
import FeedbackLink from './FeedbackLink.jsx';
|
||||||
|
|
||||||
export default function Schedule({
|
export default function Schedule({
|
||||||
conferenceId,
|
conferenceId,
|
||||||
|
@ -20,6 +22,7 @@ export default function Schedule({
|
||||||
slots,
|
slots,
|
||||||
isLoading,
|
isLoading,
|
||||||
loadingProgress,
|
loadingProgress,
|
||||||
|
isComplete,
|
||||||
} = useSchedule(conferenceId);
|
} = useSchedule(conferenceId);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -27,6 +30,7 @@ export default function Schedule({
|
||||||
rows,
|
rows,
|
||||||
} = useScheduleTable({
|
} = useScheduleTable({
|
||||||
events,
|
events,
|
||||||
|
tracks,
|
||||||
halls,
|
halls,
|
||||||
slots,
|
slots,
|
||||||
lang,
|
lang,
|
||||||
|
@ -34,9 +38,8 @@ export default function Schedule({
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
{isLoading && <progress value={loadingProgress}/>}
|
{isLoading && <progress value={loadingProgress}/>}
|
||||||
<div className="schedule">
|
{isComplete && <div className="schedule">
|
||||||
<hr />
|
<hr />
|
||||||
{header && rows && <>
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -57,8 +60,6 @@ export default function Schedule({
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
<div className="separator"/>
|
<div className="separator"/>
|
||||||
</>}
|
|
||||||
{tracks && <>
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
{Object.entries(tracks).filter(([, track]) =>
|
{Object.entries(tracks).filter(([, track]) =>
|
||||||
|
@ -72,19 +73,11 @@ export default function Schedule({
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div className="separator" />
|
<div className="separator" />
|
||||||
</>}
|
{Object.entries(events).map(([eventId, event]) => <section key={eventId} id={'lecture-'.concat(eventId)}>
|
||||||
{events && tracks && Object.entries(events).map(([eventId, event]) => <section key={eventId} id={'lecture-'.concat(eventId)}>
|
|
||||||
<p>
|
<p>
|
||||||
<strong>{event.title}</strong>
|
<strong>{event.title}</strong>
|
||||||
{event.participant_user_ids && !isTrackHidden(tracks[event.track_id]) && speakers && <>
|
{event.participant_users && !isTrackHidden(event.track) && <>
|
||||||
({event.participant_user_ids.map(speakerId => speakers[speakerId] && <Fragment key={speakerId}>
|
({event.participant_users.map(speaker => speaker && <Speaker key={speaker.id} {...speaker} />)})
|
||||||
<a key={speakerId} href={'#'.concat(getSpeakerName(speakers[speakerId]))}>
|
|
||||||
{getSpeakerName(speakers[speakerId])}
|
|
||||||
</a>
|
|
||||||
{speakers[speakerId].organisation && <>
|
|
||||||
/⁠{speakers[speakerId].organisation}⁠/
|
|
||||||
</>}
|
|
||||||
</Fragment>).filter(item => !!item)})
|
|
||||||
</>}
|
</>}
|
||||||
</p>
|
</p>
|
||||||
{event.abstract && <p>
|
{event.abstract && <p>
|
||||||
|
@ -92,12 +85,12 @@ export default function Schedule({
|
||||||
</p>}
|
</p>}
|
||||||
<p className="feedback">
|
<p className="feedback">
|
||||||
<strong>
|
<strong>
|
||||||
<a href={event.feedback_url}>Submit feedback</a>
|
<FeedbackLink {...event} />
|
||||||
</strong>
|
</strong>
|
||||||
</p>
|
</p>
|
||||||
<div className="separator" />
|
<div className="separator" />
|
||||||
</section>)}
|
</section>)}
|
||||||
{speakers && <>
|
{<>
|
||||||
<div className="grid members">
|
<div className="grid members">
|
||||||
{Object.entries(speakers).map(([speakerId, speaker]) => <div key={speakerId} className="col4 wmember">
|
{Object.entries(speakers).map(([speakerId, speaker]) => <div key={speakerId} className="col4 wmember">
|
||||||
<a href={'#'.concat(getSpeakerName(speaker))}>
|
<a href={'#'.concat(getSpeakerName(speaker))}>
|
||||||
|
@ -122,7 +115,7 @@ export default function Schedule({
|
||||||
<div className="separator" />
|
<div className="separator" />
|
||||||
</Fragment>)}
|
</Fragment>)}
|
||||||
</>}
|
</>}
|
||||||
</div>
|
</div>}
|
||||||
</>);
|
</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { getSpeakerName } from './utils.js';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
export default function Speaker(speaker) {
|
||||||
|
return (<>
|
||||||
|
<a href={'#'.concat(getSpeakerName(speaker))}>{getSpeakerName(speaker)}</a>
|
||||||
|
{speaker.organisation && <>/⁠{speaker.organisation}⁠/</>}
|
||||||
|
</>);
|
||||||
|
}
|
||||||
|
|
||||||
|
Speaker.propTypes = {
|
||||||
|
first_name: PropTypes.string.isRequired,
|
||||||
|
last_name: PropTypes.string.isRequired,
|
||||||
|
organisation: PropTypes.string,
|
||||||
|
};
|
|
@ -4,45 +4,65 @@ import useTracks from './useTracks.js';
|
||||||
import useEventTypes from './useEventTypes.js';
|
import useEventTypes from './useEventTypes.js';
|
||||||
import useHalls from './useHalls.js';
|
import useHalls from './useHalls.js';
|
||||||
import useSlots from './useSlots.js';
|
import useSlots from './useSlots.js';
|
||||||
import { calculateProgress } from '../utils.js';
|
import { addIdAndRelations, calculateProgress } from '../utils.js';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
export default function useSchedule(conferenceId) {
|
export default function useSchedule(conferenceId) {
|
||||||
const {
|
const {
|
||||||
data: events,
|
data: speakersResponse,
|
||||||
isLoading: eventsLoading,
|
|
||||||
isValidating: eventsValidating,
|
|
||||||
} = useEvents(conferenceId);
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: speakers,
|
|
||||||
isLoading: speakersLoading,
|
isLoading: speakersLoading,
|
||||||
isValidating: speakersValidating,
|
isValidating: speakersValidating,
|
||||||
} = useSpeakers(conferenceId);
|
} = useSpeakers(conferenceId);
|
||||||
|
|
||||||
|
const speakers = useMemo(() => addIdAndRelations(speakersResponse || []), [speakersResponse]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: tracks,
|
data: tracksResponse,
|
||||||
isLoading: tracksLoading,
|
isLoading: tracksLoading,
|
||||||
isValidating: tracksValidating,
|
isValidating: tracksValidating,
|
||||||
} = useTracks(conferenceId);
|
} = useTracks(conferenceId);
|
||||||
|
|
||||||
|
const tracks = useMemo(() => addIdAndRelations(tracksResponse || []), [tracksResponse]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: eventTypes,
|
data: eventTypesResponse,
|
||||||
isLoading: eventTypesLoading,
|
isLoading: eventTypesLoading,
|
||||||
isValidating: eventTypesValidating,
|
isValidating: eventTypesValidating,
|
||||||
} = useEventTypes(conferenceId);
|
} = useEventTypes(conferenceId);
|
||||||
|
|
||||||
|
const eventTypes = useMemo(() => addIdAndRelations(eventTypesResponse || []), [eventTypesResponse]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: halls,
|
data: hallsResponse,
|
||||||
isLoading: hallsLoading,
|
isLoading: hallsLoading,
|
||||||
isValidating: hallsValidating,
|
isValidating: hallsValidating,
|
||||||
} = useHalls(conferenceId);
|
} = useHalls(conferenceId);
|
||||||
|
|
||||||
|
const halls = useMemo(() => addIdAndRelations(hallsResponse || []), [hallsResponse]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: slots,
|
data: eventsResponse,
|
||||||
|
isLoading: eventsLoading,
|
||||||
|
isValidating: eventsValidating,
|
||||||
|
} = useEvents(conferenceId);
|
||||||
|
|
||||||
|
const events = useMemo(() => addIdAndRelations(eventsResponse || [], [
|
||||||
|
['event_type', eventTypes, 'event_type_id'],
|
||||||
|
['track', tracks, 'track_id'],
|
||||||
|
['participant_users', speakers, 'participant_user_ids'],
|
||||||
|
]), [eventsResponse, eventTypes, tracks, speakers]);
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: slotsResponse,
|
||||||
isLoading: slotsLoading,
|
isLoading: slotsLoading,
|
||||||
isValidating: slotsValidating,
|
isValidating: slotsValidating,
|
||||||
} = useSlots(conferenceId);
|
} = useSlots(conferenceId);
|
||||||
|
|
||||||
|
const slots = useMemo(() => addIdAndRelations(slotsResponse || [], [
|
||||||
|
['hall', halls, 'hall_id'],
|
||||||
|
['event', events, 'event_id'],
|
||||||
|
]), [slotsResponse, halls, events]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isStarted: isLoading,
|
isStarted: isLoading,
|
||||||
remainingProgress: loadingProgress,
|
remainingProgress: loadingProgress,
|
||||||
|
@ -53,6 +73,10 @@ export default function useSchedule(conferenceId) {
|
||||||
remainingProgress: validatingProgress,
|
remainingProgress: validatingProgress,
|
||||||
} = calculateProgress(eventsValidating, speakersValidating, tracksValidating, eventTypesValidating, hallsValidating, slotsValidating);
|
} = calculateProgress(eventsValidating, speakersValidating, tracksValidating, eventTypesValidating, hallsValidating, slotsValidating);
|
||||||
|
|
||||||
|
const {
|
||||||
|
isComplete,
|
||||||
|
} = calculateProgress(events, speakers, tracks, eventTypes, halls, slots);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
events,
|
events,
|
||||||
speakers,
|
speakers,
|
||||||
|
@ -64,5 +88,6 @@ export default function useSchedule(conferenceId) {
|
||||||
loadingProgress,
|
loadingProgress,
|
||||||
isValidating,
|
isValidating,
|
||||||
validatingProgress,
|
validatingProgress,
|
||||||
|
isComplete,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ export default function useScheduleTable({
|
||||||
cells: [{
|
cells: [{
|
||||||
id: 1,
|
id: 1,
|
||||||
attributes: {
|
attributes: {
|
||||||
|
className: 'schedule-'.concat(event.language).concat(' ').concat(event.track.css_class),
|
||||||
colSpan: 2,
|
colSpan: 2,
|
||||||
},
|
},
|
||||||
event,
|
event,
|
||||||
|
|
12
src/utils.js
12
src/utils.js
|
@ -41,3 +41,15 @@ export function calculateProgress(...elements) {
|
||||||
isNotStarted: completeCount === 0,
|
isNotStarted: completeCount === 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addIdAndRelations = (items, relations = []) =>
|
||||||
|
Object.fromEntries(Object.entries(items).map(([id, item]) =>
|
||||||
|
([id, {
|
||||||
|
id,
|
||||||
|
...item,
|
||||||
|
...Object.fromEntries(relations.map(([field, collection, idField]) => ([
|
||||||
|
field,
|
||||||
|
Array.isArray(item[idField]) ? item[idField].map(id => collection[id]) : collection[item[idField]],
|
||||||
|
]))),
|
||||||
|
}])
|
||||||
|
));
|
||||||
|
|
Loading…
Reference in New Issue