diff --git a/src/ScheduleLoader.jsx b/src/ScheduleLoader.jsx index 46487da..58aad14 100644 --- a/src/ScheduleLoader.jsx +++ b/src/ScheduleLoader.jsx @@ -1,14 +1,17 @@ import useConferences from './hooks/useConferences.js'; -import { useState } from 'react'; +import { useMemo, useState } from 'react'; import Schedule from './Schedule.jsx'; +import { dateSorter } from './utils.js'; export default function ScheduleLoader() { const { - conferences, + data, error, isLoading, } = useConferences(); + const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]); + const [ conferenceId, setConferenceId ] = useState(); return (<> diff --git a/src/hooks/useConferences.js b/src/hooks/useConferences.js index 676a099..ca45c2a 100644 --- a/src/hooks/useConferences.js +++ b/src/hooks/useConferences.js @@ -1,17 +1,5 @@ import useCfpRequest from './useCfpRequest.js'; -import { useMemo } from 'react'; -import { dateSorter } from '../utils.js'; export default function useConferences() { - const { - data, - ...rest - } = useCfpRequest(); - - const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]); - - return { - conferences, - ...rest, - }; + return useCfpRequest(); } diff --git a/src/hooks/useEventTypes.js b/src/hooks/useEventTypes.js new file mode 100644 index 0000000..2ed66ba --- /dev/null +++ b/src/hooks/useEventTypes.js @@ -0,0 +1,5 @@ +import useCfpRequest from './useCfpRequest.js'; + +export default function useEventTypes(conferenceId) { + return useCfpRequest(`${conferenceId}/event_types.json`); +} diff --git a/src/hooks/useEvents.js b/src/hooks/useEvents.js new file mode 100644 index 0000000..d72857f --- /dev/null +++ b/src/hooks/useEvents.js @@ -0,0 +1,5 @@ +import useCfpRequest from './useCfpRequest.js'; + +export default function useEvents(conferenceId) { + return useCfpRequest(`${conferenceId}/events.json`); +} diff --git a/src/hooks/useHalls.js b/src/hooks/useHalls.js new file mode 100644 index 0000000..7d46c9a --- /dev/null +++ b/src/hooks/useHalls.js @@ -0,0 +1,5 @@ +import useCfpRequest from './useCfpRequest.js'; + +export default function useHalls(conferenceId) { + return useCfpRequest(`${conferenceId}/halls.json`); +} diff --git a/src/hooks/useSlots.js b/src/hooks/useSlots.js new file mode 100644 index 0000000..19f9f11 --- /dev/null +++ b/src/hooks/useSlots.js @@ -0,0 +1,5 @@ +import useCfpRequest from './useCfpRequest.js'; + +export default function useSlots(conferenceId) { + return useCfpRequest(`${conferenceId}/slots.json`); +} diff --git a/src/hooks/useSpeakers.js b/src/hooks/useSpeakers.js new file mode 100644 index 0000000..8503128 --- /dev/null +++ b/src/hooks/useSpeakers.js @@ -0,0 +1,5 @@ +import useCfpRequest from './useCfpRequest.js'; + +export default function useSpeakers(conferenceId) { + return useCfpRequest(`${conferenceId}/speakers.json`); +} diff --git a/src/hooks/useTracks.js b/src/hooks/useTracks.js new file mode 100644 index 0000000..90c6d27 --- /dev/null +++ b/src/hooks/useTracks.js @@ -0,0 +1,5 @@ +import useCfpRequest from './useCfpRequest.js'; + +export default function useTracks(conferenceId) { + return useCfpRequest(`${conferenceId}/tracks.json`); +}