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 ( <>