From 99328fbbf9dca40cce8f007430a27817384a5e62 Mon Sep 17 00:00:00 2001 From: Gilles Dubreuil Date: Wed, 20 Sep 2023 10:20:08 +0200 Subject: [PATCH] Use isAssessmentsFetching Signed-off-by: Gilles Dubreuil --- client/src/app/pages/reports/reports.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/client/src/app/pages/reports/reports.tsx b/client/src/app/pages/reports/reports.tsx index f0910f1a98..d6a3c0b83a 100644 --- a/client/src/app/pages/reports/reports.tsx +++ b/client/src/app/pages/reports/reports.tsx @@ -50,7 +50,8 @@ export const Reports: React.FC = () => { const [selectedQuestionnaire, setSelectedQuestionnaire] = React.useState("All questionnaires"); - const { assessments } = useFetchAssessments(); + const { assessments, isFetching: isAssessmentsFetching } = + useFetchAssessments(); // Cards const [isAdoptionCandidateTable, setIsAdoptionCandidateTable] = @@ -103,12 +104,14 @@ export const Reports: React.FC = () => { setIsQuestionnaireSelectOpen(false); }; - const questionnaires = assessments.reduce((result: Ref[], item) => { - if (!result.some((ref) => ref.id === item.questionnaire.id)) { - result.push(item.questionnaire); - } - return result; - }, []); + const questionnaires: Ref[] = isAssessmentsFetching + ? [] + : assessments.reduce((result: Ref[], item) => { + if (!result.some((ref) => ref.id === item.questionnaire.id)) { + result.push(item.questionnaire); + } + return result; + }, []); return ( <>