Compare commits
No commits in common. "8a429b0a93dab72b5528a44b61ed5e1e17d8ccfb" and "0cd5365c93bb686e538e0020787463447d793dbb" have entirely different histories.
8a429b0a93
...
0cd5365c93
|
@ -1,8 +1,8 @@
|
|||
import './App.css';
|
||||
import ScheduleChooser from './ScheduleChooser.jsx';
|
||||
import ScheduleLoader from './ScheduleLoader.jsx';
|
||||
|
||||
function App() {
|
||||
return (<ScheduleChooser/>);
|
||||
return (<ScheduleLoader/>);
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
|
|
@ -17,7 +17,7 @@ export default function Schedule({
|
|||
} = useSchedule(conferenceId);
|
||||
|
||||
return (<>
|
||||
{isLoading && <>Loading... <progress value={loadingProgress} /></>}
|
||||
{isLoading && <p>Loading... <progress value={loadingProgress} /></p>}
|
||||
{halls && <table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -25,9 +25,7 @@ export default function Schedule({
|
|||
</tr>
|
||||
</thead>
|
||||
</table>}
|
||||
{tracks && Object.entries(tracks).filter(([, track]) =>
|
||||
!isTrackHidden(track)
|
||||
).map(([trackId, track]) => <div key={trackId} style={{
|
||||
{tracks && Object.entries(tracks).map(([trackId, track]) => <div key={trackId} style={{
|
||||
width: '100%',
|
||||
border: '1px solid black',
|
||||
textAlign: 'center',
|
||||
|
@ -87,6 +85,6 @@ export default function Schedule({
|
|||
}
|
||||
|
||||
Schedule.propTypes = {
|
||||
conferenceId: PropTypes.number.isRequired,
|
||||
conferenceId: PropTypes.string.isRequired,
|
||||
lang: PropTypes.string.isRequired,
|
||||
};
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import ScheduleLoader from './ScheduleLoader.jsx';
|
||||
|
||||
export default function ScheduleChooser({
|
||||
year = 2023,
|
||||
lang = 'bg',
|
||||
}) {
|
||||
/*
|
||||
const {
|
||||
data,
|
||||
error,
|
||||
isLoading,
|
||||
} = useConferences();
|
||||
|
||||
const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]);
|
||||
|
||||
const [ selectedConferenceId, setSelectedConferenceId ] = useState();
|
||||
const [ selectedLang, setSelectedLang ] = useState(lang);
|
||||
|
||||
return (<>
|
||||
<div>
|
||||
<select onChange={e => setSelectedLang(e.target.value)}>
|
||||
{Object.entries(langs).map(([langId, langName]) => <option key={langId} value={langId}>{langName}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
{isLoading && <p>Please wait...</p>}
|
||||
{error && <p>Error: {error}</p>}
|
||||
{conferences && <>
|
||||
<label>Select a conference</label>
|
||||
<select onChange={e => setSelectedConferenceId(e.target.value)}>
|
||||
{conferences.map(conference => <option key={conference.id}
|
||||
value={conference.id}>{conference.title}</option>)}
|
||||
</select>
|
||||
</>}
|
||||
<ScheduleLoader year={year} lang={selectedLang} />
|
||||
</>);
|
||||
*/
|
||||
return (<ScheduleLoader year={year} lang={lang} />);
|
||||
}
|
||||
|
||||
ScheduleChooser.propTypes = {
|
||||
year: PropTypes.number,
|
||||
lang: PropTypes.string,
|
||||
};
|
|
@ -1,31 +1,36 @@
|
|||
import useConferences from './hooks/useConferences.js';
|
||||
import { useMemo, useState } from 'react';
|
||||
import Schedule from './Schedule.jsx';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useMemo } from 'react';
|
||||
import { dateSorter } from './utils.js';
|
||||
import { langs } from './constants.js';
|
||||
|
||||
export default function ScheduleLoader({
|
||||
year,
|
||||
lang,
|
||||
}) {
|
||||
export default function ScheduleLoader() {
|
||||
const {
|
||||
data,
|
||||
error,
|
||||
isLoading,
|
||||
} = useConferences();
|
||||
|
||||
const conferenceId = useMemo(() => data && data.filter(conference => {
|
||||
const dt = new Date(Date.parse(conference.start_date));
|
||||
return dt.getFullYear() === year;
|
||||
})?.[0]?.id, [data, year]);
|
||||
const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]);
|
||||
|
||||
const [ conferenceId, setConferenceId ] = useState();
|
||||
const [ lang, setLang ] = useState();
|
||||
|
||||
return (<>
|
||||
{isLoading && <p>Loading conferences...</p>}
|
||||
{error && <p>Error loading conferences: {error}</p>}
|
||||
<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>}
|
||||
{error && <p>Error: {error}</p>}
|
||||
{conferences && <>
|
||||
<label>Select a conference</label>
|
||||
<select onChange={e => setConferenceId(e.target.value)}>
|
||||
{conferences.map(conference => <option key={conference.id}
|
||||
value={conference.id}>{conference.title}</option>)}
|
||||
</select>
|
||||
</>}
|
||||
{conferenceId && <Schedule conferenceId={conferenceId} lang={lang} />}
|
||||
</>);
|
||||
}
|
||||
|
||||
ScheduleLoader.propTypes = {
|
||||
year: PropTypes.number,
|
||||
lang: PropTypes.string,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue