Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 27x | import React from 'react';
import { useQuery } from 'react-query';
import { useOkapiKy } from '@folio/stripes/core';
const useTemplates = ({ context, endpoint, queryParams, sort }) => {
const ky = useOkapiKy();
const extraPathItems = [];
if (context) {
extraPathItems.push(`filters=context=${context}`);
}
if (sort) {
extraPathItems.push(`sort=${sort}`);
}
extraPathItems.push('max=500');
const path = `${endpoint}?${extraPathItems.join('&')}`;
const { data: templates } = useQuery(
['stripes-kint-components', 'useTemplates', 'templates', context ?? ''],
() => ky(path).json(),
queryParams
);
return templates || [];
};
export default useTemplates;
|