From c56ab0fc66b5e62e06df903078bce2dacef25626 Mon Sep 17 00:00:00 2001 From: Arnaud AMBROSELLI Date: Fri, 6 Oct 2023 09:13:51 +0200 Subject: [PATCH] fix: restricted roles --- dashboard/src/components/DataLoader.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dashboard/src/components/DataLoader.js b/dashboard/src/components/DataLoader.js index 1f1c48c7be..aba572964d 100644 --- a/dashboard/src/components/DataLoader.js +++ b/dashboard/src/components/DataLoader.js @@ -164,9 +164,11 @@ export function useDataLoader(options = { refreshOnMount: false }) { stats.relsPersonPlace + stats.territoryObservations + stats.comments + - stats.consultations + - stats.treatments + - stats.medicalFiles; + stats.consultations; + + if (['admin', 'normal'].includes(latestUser.role)) { + itemsCount += stats.treatments + stats.medicalFiles; + } setProgress(0); setTotal(itemsCount); @@ -358,7 +360,7 @@ export function useDataLoader(options = { refreshOnMount: false }) { const consultationsSuccess = await loadConsultations(0); if (!consultationsSuccess) return false; } - if (stats.treatments > 0) { + if (['admin', 'normal'].includes(latestUser.role) && stats.treatments > 0) { let newItems = []; setLoadingText('Chargement des traitements'); async function loadTreatments(page = 0) { @@ -373,7 +375,7 @@ export function useDataLoader(options = { refreshOnMount: false }) { const treatmentsSuccess = await loadTreatments(0); if (!treatmentsSuccess) return false; } - if (stats.medicalFiles > 0) { + if (['admin', 'normal'].includes(latestUser.role) && stats.medicalFiles > 0) { let newItems = []; setLoadingText('Chargement des fichiers médicaux'); async function loadMedicalFiles(page = 0) {