From 7b040de51d9c5193aea8905cd981ff9de63b8b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Demazi=C3=A8re?= Date: Tue, 13 Feb 2024 15:38:50 +0100 Subject: [PATCH] Develop (#102) * fix closing cause in list SU * Update package.json --- package.json | 2 +- src/components/ListSU/SurveyUnitLine.jsx | 3 ++- src/utils/Utils.js | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4497ab6..7a11bd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sonor", - "version": "0.5.32", + "version": "0.5.33", "private": true, "dependencies": { "@testing-library/jest-dom": "^4.2.4", diff --git a/src/components/ListSU/SurveyUnitLine.jsx b/src/components/ListSU/SurveyUnitLine.jsx index 9638563..bc4ee14 100644 --- a/src/components/ListSU/SurveyUnitLine.jsx +++ b/src/components/ListSU/SurveyUnitLine.jsx @@ -17,6 +17,7 @@ function SurveyUnitLine({ state, remindersByOrder = [], contactOutcome, + closingCause, } = lineData; const getReminderDescription = (reminder) => { @@ -115,7 +116,7 @@ function SurveyUnitLine({ )} - {state ? D[state] : ""} + {closingCause ? D[closingCause] : ""} ); } diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 86fb3ea..18b6a29 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -186,8 +186,7 @@ class Utils { 'survey', 'site', 'date', - 'finalizationDate', - 'state', + 'finalizationDate', ]; if (labelsSimpleSort.includes(sortOn)) { return (a, b) => { @@ -200,6 +199,21 @@ class Utils { return mainSort ? mainSortFunc(a, b) : 0; }; } + if (sortOn === 'state') { + return (a, b) => { + const aState = a.closingCause ? D[a.closingCause] : undefined; + const bState = b.closingCause ? D[b.closingCause] : undefined; + + if(!aState || !bState){ + return aState ? -1 * mult : 1 * mult; + } + if (aState !== bState) { + return (aState < bState ? -1 : 1) * mult; + } + return mainSort ? mainSortFunc(a, b) : 0; + }; + } + if (sortOn === 'CPinterviewer') { return (a, b) => { const aString = a.interviewerLastName + a.interviewerFirstName;