Skip to content

Commit

Permalink
Use isAssessmentsFetching
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Dubreuil <[email protected]>
  • Loading branch information
gildub committed Sep 20, 2023
1 parent b3e8e4a commit 99328fb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions client/src/app/pages/reports/reports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export const Reports: React.FC = () => {
const [selectedQuestionnaire, setSelectedQuestionnaire] =
React.useState<string>("All questionnaires");

const { assessments } = useFetchAssessments();
const { assessments, isFetching: isAssessmentsFetching } =
useFetchAssessments();

// Cards
const [isAdoptionCandidateTable, setIsAdoptionCandidateTable] =
Expand Down Expand Up @@ -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 (
<>
Expand Down

0 comments on commit 99328fb

Please sign in to comment.