Render tracks and events
This commit is contained in:
parent
38e52b25d8
commit
3752ddbe4f
|
@ -1,49 +1,64 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import useSchedule from './hooks/useSchedule.js';
|
import useSchedule from './hooks/useSchedule.js';
|
||||||
|
import { getSpeakerName, isTrackHidden } from './utils.js';
|
||||||
|
import { Fragment } from 'react';
|
||||||
|
|
||||||
export default function Schedule({
|
export default function Schedule({
|
||||||
conferenceId,
|
conferenceId,
|
||||||
|
lang,
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
events,
|
events,
|
||||||
speakers,
|
speakers,
|
||||||
tracks,
|
tracks,
|
||||||
eventTypes,
|
|
||||||
halls,
|
|
||||||
slots,
|
|
||||||
isLoading,
|
isLoading,
|
||||||
} = useSchedule(conferenceId);
|
} = useSchedule(conferenceId);
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
<div>conference id: {conferenceId}</div>
|
|
||||||
{isLoading && <p>Loading...</p>}
|
{isLoading && <p>Loading...</p>}
|
||||||
{events && <>
|
<div>schedule goes here</div>
|
||||||
<div>events:</div>
|
{tracks && Object.entries(tracks).map(([trackId, track]) => <div key={trackId} style={{
|
||||||
<div>{JSON.stringify(events)}</div>
|
width: '100%',
|
||||||
</>}
|
border: '1px solid black',
|
||||||
|
textAlign: 'center',
|
||||||
|
margin: '4px 0',
|
||||||
|
padding: '4px 0',
|
||||||
|
}}>{track.name[lang]}
|
||||||
|
</div>)}
|
||||||
|
{events && Object.entries(events).map(([eventId, event]) => <section key={eventId} id={'lecture-'.concat(eventId)}>
|
||||||
|
<p>
|
||||||
|
<strong>{event.title}</strong>
|
||||||
|
{event.participant_user_ids && !isTrackHidden(tracks[event.track_id]) && speakers && <>
|
||||||
|
({event.participant_user_ids.map(speakerId => speakers[speakerId] && <Fragment key={speakerId}>
|
||||||
|
<a key={speakerId} href={'#'.concat(getSpeakerName(speakers[speakerId]))}>
|
||||||
|
{getSpeakerName(speakers[speakerId])}
|
||||||
|
</a>
|
||||||
|
{speakers[speakerId].organisation && <>
|
||||||
|
/{speakers[speakerId].organisation}/
|
||||||
|
</>}
|
||||||
|
</Fragment>).filter(item => !!item)})
|
||||||
|
</>}
|
||||||
|
</p>
|
||||||
|
{event.abstract && <p>
|
||||||
|
{event.abstract}
|
||||||
|
</p>}
|
||||||
|
<p style={{
|
||||||
|
textAlign: 'right',
|
||||||
|
}}>
|
||||||
|
<strong>
|
||||||
|
<a href={event.feedback_url}>Submit feedback</a>
|
||||||
|
</strong>
|
||||||
|
</p>
|
||||||
|
<hr />
|
||||||
|
</section>)}
|
||||||
{speakers && <>
|
{speakers && <>
|
||||||
<div>speakers:</div>
|
<div>speakers:</div>
|
||||||
<div>{JSON.stringify(speakers)}</div>
|
<div>{JSON.stringify(speakers)}</div>
|
||||||
</>}
|
</>}
|
||||||
{tracks && <>
|
|
||||||
<div>tracks:</div>
|
|
||||||
<div>{JSON.stringify(tracks)}</div>
|
|
||||||
</>}
|
|
||||||
{eventTypes && <>
|
|
||||||
<div>event types:</div>
|
|
||||||
<div>{JSON.stringify(eventTypes)}</div>
|
|
||||||
</>}
|
|
||||||
{halls && <>
|
|
||||||
<div>halls:</div>
|
|
||||||
<div>{JSON.stringify(halls)}</div>
|
|
||||||
</>}
|
|
||||||
{slots && <>
|
|
||||||
<div>slots:</div>
|
|
||||||
<div>{JSON.stringify(slots)}</div>
|
|
||||||
</>}
|
|
||||||
</>);
|
</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
Schedule.propTypes = {
|
Schedule.propTypes = {
|
||||||
conferenceId: PropTypes.string.isRequired,
|
conferenceId: PropTypes.string.isRequired,
|
||||||
|
lang: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@ import useConferences from './hooks/useConferences.js';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import Schedule from './Schedule.jsx';
|
import Schedule from './Schedule.jsx';
|
||||||
import { dateSorter } from './utils.js';
|
import { dateSorter } from './utils.js';
|
||||||
|
import { langs } from './constants.js';
|
||||||
|
|
||||||
export default function ScheduleLoader() {
|
export default function ScheduleLoader() {
|
||||||
const {
|
const {
|
||||||
|
@ -13,8 +14,14 @@ export default function ScheduleLoader() {
|
||||||
const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]);
|
const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]);
|
||||||
|
|
||||||
const [ conferenceId, setConferenceId ] = useState();
|
const [ conferenceId, setConferenceId ] = useState();
|
||||||
|
const [ lang, setLang ] = useState();
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
|
<div>
|
||||||
|
<select onChange={e => setLang(e.target.value)}>
|
||||||
|
{Object.entries(langs).map(([langId, langName]) => <option key={langId} value={langId}>{langName}</option>)}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
{isLoading && <p>Please wait...</p>}
|
{isLoading && <p>Please wait...</p>}
|
||||||
{error && <p>Error: {error}</p>}
|
{error && <p>Error: {error}</p>}
|
||||||
{conferences && <>
|
{conferences && <>
|
||||||
|
@ -24,8 +31,6 @@ export default function ScheduleLoader() {
|
||||||
value={conference.id}>{conference.title}</option>)}
|
value={conference.id}>{conference.title}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</>}
|
</>}
|
||||||
{conferenceId && <div>
|
{conferenceId && <Schedule conferenceId={conferenceId} lang={lang} />}
|
||||||
<Schedule conferenceId={conferenceId} />
|
|
||||||
</div>}
|
|
||||||
</>);
|
</>);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
export const langs = {
|
||||||
|
en: 'English',
|
||||||
|
bg: 'Български',
|
||||||
|
};
|
|
@ -8,3 +8,7 @@ function sorter(a, b, fieldFn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dateSorter = key => (a, b) => sorter(a, b, item => Date.parse(item[key]));
|
export const dateSorter = key => (a, b) => sorter(a, b, item => Date.parse(item[key]));
|
||||||
|
|
||||||
|
export const getSpeakerName = speaker => speaker.first_name.concat(' ').concat(speaker.last_name);
|
||||||
|
|
||||||
|
export const isTrackHidden = track => track.name.en === 'Other' || track.name.bg === 'Други';
|
||||||
|
|
Loading…
Reference in New Issue