diff --git a/src/Frameworks/AsyncTableTools/utils/withExport/withExport.js b/src/Frameworks/AsyncTableTools/utils/withExport/withExport.js index c20481876..d8a3aec74 100644 --- a/src/Frameworks/AsyncTableTools/utils/withExport/withExport.js +++ b/src/Frameworks/AsyncTableTools/utils/withExport/withExport.js @@ -42,6 +42,7 @@ const withExport = ({ downloadItems(exportColumns, items, format); onComplete?.(items); } catch (error) { + console.error(error); onError?.(error); } }; diff --git a/src/PresentationalComponents/Tailorings/components/TailoringTab.js b/src/PresentationalComponents/Tailorings/components/TailoringTab.js index d5ed81f50..91ec141cd 100644 --- a/src/PresentationalComponents/Tailorings/components/TailoringTab.js +++ b/src/PresentationalComponents/Tailorings/components/TailoringTab.js @@ -86,10 +86,12 @@ const TailoringTab = ({ ) : undefined; + // TODO The wrapping of the fetches in an array is odd. + // Figure out why this is and how we can avoid it const exporter = async () => (tailoring && policy - ? await fetchBatchedTailoringRules() - : await fetchBatchedRules() + ? [await fetchBatchedTailoringRules()] + : [await fetchBatchedRules()] ).flatMap((result) => result.data); const itemIdsInTable = async () => diff --git a/src/Utilities/hooks/useFetchTotalBatched.js b/src/Utilities/hooks/useFetchTotalBatched.js index 612e6cde4..b4995006a 100644 --- a/src/Utilities/hooks/useFetchTotalBatched.js +++ b/src/Utilities/hooks/useFetchTotalBatched.js @@ -17,10 +17,15 @@ const useFetchTotalBatched = (fetchFn, options = {}) => { const [totalResult, setTotalResult] = useState(); const fetch = useCallback( - async (params = {}) => { + async (fetchParams = {}) => { + const allParams = { + ...params, + ...fetchParams, + }; + if (!loading.current) { loading.current = true; - const firstPage = await fetchFn(0, batchSize, params); + const firstPage = await fetchFn(0, batchSize, allParams); const total = firstPage?.meta?.total; if (total > batchSize) { @@ -30,7 +35,7 @@ const useFetchTotalBatched = (fetchFn, options = {}) => { const page = pageIdx; if (page >= 1) { const offset = page * batchSize; - return await fetchFn(offset, batchSize, params); + return await fetchFn(offset, batchSize, allParams); } } ); @@ -60,7 +65,7 @@ const useFetchTotalBatched = (fetchFn, options = {}) => { } } }, - [typeof fetchFn !== 'undefined', batchSize] + [typeof fetchFn !== 'undefined', batchSize, JSON.stringify(params)] ); useDeepCompareEffectNoCheck(() => {