Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix closing cause in list SU #101

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sonor",
"version": "0.5.32",
"version": "0.5.33",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
Expand Down
3 changes: 2 additions & 1 deletion src/components/ListSU/SurveyUnitLine.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function SurveyUnitLine({
state,
remindersByOrder = [],
contactOutcome,
closingCause,
} = lineData;

const getReminderDescription = (reminder) => {
Expand Down Expand Up @@ -115,7 +116,7 @@ function SurveyUnitLine({
</td>
</>
)}
<td className="ColState">{state ? D[state] : ""}</td>
<td className="ColState">{closingCause ? D[closingCause] : ""}</td>
</tr>
);
}
Expand Down
18 changes: 16 additions & 2 deletions src/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ class Utils {
'survey',
'site',
'date',
'finalizationDate',
'state',
'finalizationDate',
];
if (labelsSimpleSort.includes(sortOn)) {
return (a, b) => {
Expand All @@ -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;
Expand Down
Loading