Conference selection

This commit is contained in:
Vencislav Atanasov 2024-09-18 21:40:20 +03:00
parent cba2439f11
commit ff715b610b
2 changed files with 21 additions and 1 deletions

13
src/Schedule.jsx Normal file
View File

@ -0,0 +1,13 @@
import PropTypes from 'prop-types';
export default function Schedule({
conferenceId,
}) {
return (<>
conference id: {conferenceId}
</>);
}
Schedule.propTypes = {
conferenceId: PropTypes.string.isRequired,
};

View File

@ -1,4 +1,6 @@
import useConferences from './hooks/useConferences.js'; import useConferences from './hooks/useConferences.js';
import { useState } from 'react';
import Schedule from './Schedule.jsx';
export default function ScheduleLoader() { export default function ScheduleLoader() {
const { const {
@ -7,15 +9,20 @@ export default function ScheduleLoader() {
isLoading, isLoading,
} = useConferences(); } = useConferences();
const [ conferenceId, setConferenceId ] = useState();
return (<> return (<>
{isLoading && <p>Please wait...</p>} {isLoading && <p>Please wait...</p>}
{error && <p>Error: {error}</p>} {error && <p>Error: {error}</p>}
{conferences && <> {conferences && <>
<label>Select a conference</label> <label>Select a conference</label>
<select> <select onChange={e => setConferenceId(e.target.value)}>
{conferences.map(conference => <option key={conference.id} {conferences.map(conference => <option key={conference.id}
value={conference.id}>{conference.title}</option>)} value={conference.id}>{conference.title}</option>)}
</select> </select>
</>} </>}
{conferenceId && <div>
<Schedule conferenceId={conferenceId} />
</div>}
</>); </>);
} }