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 { 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 (<>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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