diff --git a/dashboard/src/components/EvolutiveStatsViewer.tsx b/dashboard/src/components/EvolutiveStatsViewer.tsx
index 61474dd6e..a2702b745 100644
--- a/dashboard/src/components/EvolutiveStatsViewer.tsx
+++ b/dashboard/src/components/EvolutiveStatsViewer.tsx
@@ -69,27 +69,32 @@ export default function EvolutiveStatsViewer({ evolutiveStatsIndicators, period,
{fieldStart}
-
-
-
{Math.round((valueEnd / valueStart) * 1000) / 10}%
-
- des{' '}
-
- {field?.label}: {fieldStart}
- {' '}
- au {startDateFormatted.format('DD/MM/YYYY')}
-
- ont évolué vers {fieldEnd} au {endDateFormatted.format('DD/MM/YYYY')}
-
-
-
-
-
Au {endDateFormatted.format('DD/MM/YYYY')}
-
-
{valueEnd}
-
{fieldEnd}
-
-
+ {valueStart !== 0 && (
+ <>
+
+
+
{Math.round((valueEnd / valueStart) * 1000) / 10}%
+
+ des{' '}
+
+ {field?.label}: {fieldStart}
+ {' '}
+ au {startDateFormatted.format('DD/MM/YYYY')}
+
+ {fieldStart === fieldEnd ? ' sont restés à ' : ' ont évolué vers '}
+ {fieldEnd} au {endDateFormatted.format('DD/MM/YYYY')}
+
+
+
+
+
Au {endDateFormatted.format('DD/MM/YYYY')}
+
+
{valueEnd}
+
{fieldEnd}
+
+
+ >
+ )}
);
}
diff --git a/dashboard/src/recoil/evolutiveStats.ts b/dashboard/src/recoil/evolutiveStats.ts
index c020f470d..5d2787f48 100644
--- a/dashboard/src/recoil/evolutiveStats.ts
+++ b/dashboard/src/recoil/evolutiveStats.ts
@@ -70,8 +70,17 @@ function getValueByField(fieldName: CustomOrPredefinedField['name'], fieldsMap:
if (value === true) return 'Oui';
return 'Non';
}
+ if (current.type === 'multi-choice') {
+ if (Array.isArray(value)) {
+ if (value.length === 0) return ['Non renseigné'];
+ return value;
+ }
+ if (value == null || value === '') {
+ return ['Non renseigné'];
+ }
+ return [value];
+ }
if (value == null || value === '') {
- if (current.type === 'multi-choice') return [];
return 'Non renseigné'; // we cover the case of undefined, null, empty string
}
if (value.includes('Choisissez un genre')) return 'Non renseigné';
@@ -145,7 +154,10 @@ export const evolutiveStatsPersonSelector = selectorFamily({
// how do we calculate ?
// we start by the most recent version of the person, and we go back in time, day by day, to the beginning of the history
- const indicatorsBase = get(evolutiveStatsIndicatorsBaseSelector);
+ const indicatorsBase = get(evolutiveStatsIndicatorsBaseSelector).filter((f) => {
+ if (evolutiveStatsIndicators.find((i) => i.fieldName === f.name)) return true;
+ return false;
+ });
const fieldsMap: FieldsMap = indicatorsBase.reduce((acc, field) => {
acc[field.name] = field;
return acc;
@@ -178,7 +190,8 @@ export const evolutiveStatsPersonSelector = selectorFamily({
persons = persons.filter((p) => {
const snapshot = getPersonSnapshotAtDate({ person: p, snapshotDate: minimumDateForEvolutiveStats, fieldsMap });
if (!snapshot) return false;
- return getValueByField(indicatorFieldName, fieldsMap, p[indicatorFieldName]).includes(indicator.fromValue);
+ const isGood = getValueByField(indicatorFieldName, fieldsMap, snapshot[indicatorFieldName]).includes(indicator.fromValue);
+ return isGood;
});
}