Add hooks for all requests
This commit is contained in:
parent
ff715b610b
commit
c6e1ed6ef1
|
@ -1,14 +1,17 @@
|
||||||
import useConferences from './hooks/useConferences.js';
|
import useConferences from './hooks/useConferences.js';
|
||||||
import { useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import Schedule from './Schedule.jsx';
|
import Schedule from './Schedule.jsx';
|
||||||
|
import { dateSorter } from './utils.js';
|
||||||
|
|
||||||
export default function ScheduleLoader() {
|
export default function ScheduleLoader() {
|
||||||
const {
|
const {
|
||||||
conferences,
|
data,
|
||||||
error,
|
error,
|
||||||
isLoading,
|
isLoading,
|
||||||
} = useConferences();
|
} = useConferences();
|
||||||
|
|
||||||
|
const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]);
|
||||||
|
|
||||||
const [ conferenceId, setConferenceId ] = useState();
|
const [ conferenceId, setConferenceId ] = useState();
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
import useCfpRequest from './useCfpRequest.js';
|
import useCfpRequest from './useCfpRequest.js';
|
||||||
import { useMemo } from 'react';
|
|
||||||
import { dateSorter } from '../utils.js';
|
|
||||||
|
|
||||||
export default function useConferences() {
|
export default function useConferences() {
|
||||||
const {
|
return useCfpRequest();
|
||||||
data,
|
|
||||||
...rest
|
|
||||||
} = useCfpRequest();
|
|
||||||
|
|
||||||
const conferences = useMemo(() => Array.isArray(data) ? data.sort(dateSorter('start_date')) : data, [data]);
|
|
||||||
|
|
||||||
return {
|
|
||||||
conferences,
|
|
||||||
...rest,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import useCfpRequest from './useCfpRequest.js';
|
||||||
|
|
||||||
|
export default function useEventTypes(conferenceId) {
|
||||||
|
return useCfpRequest(`${conferenceId}/event_types.json`);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import useCfpRequest from './useCfpRequest.js';
|
||||||
|
|
||||||
|
export default function useEvents(conferenceId) {
|
||||||
|
return useCfpRequest(`${conferenceId}/events.json`);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import useCfpRequest from './useCfpRequest.js';
|
||||||
|
|
||||||
|
export default function useHalls(conferenceId) {
|
||||||
|
return useCfpRequest(`${conferenceId}/halls.json`);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import useCfpRequest from './useCfpRequest.js';
|
||||||
|
|
||||||
|
export default function useSlots(conferenceId) {
|
||||||
|
return useCfpRequest(`${conferenceId}/slots.json`);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import useCfpRequest from './useCfpRequest.js';
|
||||||
|
|
||||||
|
export default function useSpeakers(conferenceId) {
|
||||||
|
return useCfpRequest(`${conferenceId}/speakers.json`);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import useCfpRequest from './useCfpRequest.js';
|
||||||
|
|
||||||
|
export default function useTracks(conferenceId) {
|
||||||
|
return useCfpRequest(`${conferenceId}/tracks.json`);
|
||||||
|
}
|
Loading…
Reference in New Issue