Merged PR 1921: feat(remission-list-resource): remove client-side date sorting in favor of ba...

feat(remission-list-resource): remove client-side date sorting in favor of backend sorting

Remove commented-out date sorting logic from sortResponseResult function.
The sorting by creation date for Pflichtremission and by SORT number
for Abteilungsremission is now handled entirely by the backend,
eliminating the need for client-side date sorting operations.

This change improves performance by reducing client-side processing
and ensures consistent sorting behavior across the application.

Ref: #5295
This commit is contained in:
Nino Righi
2025-09-01 14:59:07 +00:00
committed by Andreas Schickinger
parent d2dcf638e3
commit 46c70cae3e

View File

@@ -145,11 +145,12 @@ export const createRemissionListResource = (
};
/**
* Sorts the response result of remission items.
* - Manually added items come first.
* - Then sorted by created date in descending order (latest first).
*
* @param {ListResponseArgs<RemissionItem>} resopnse - The response containing remission items to sort
* Sorts the remission items in the response based on specific criteria:
* - Items with impediments are moved to the end of the list.
* - Manually added items are prioritized to appear first.
* - (Commented out) Items can be sorted by creation date in descending order.
* @param {ListResponseArgs<RemissionItem>} resopnse - The response object containing remission items to be sorted
* @returns {void} The function modifies the response object in place
*/
const sortResponseResult = (
resopnse: ListResponseArgs<RemissionItem>,
@@ -176,16 +177,17 @@ const sortResponseResult = (
return 1;
}
// #5295 Fix - Sortierung über Created (Pflichtremission) wird wie auch die Sortierung über die SORT Nummer (Abteilungsremission) bereits über das Backend erledigt
// Third priority: sort by created date (latest first)
if (a.created && b.created) {
const dateA = parseISO(a.created);
const dateB = parseISO(b.created);
return compareDesc(dateA, dateB); // Descending order (latest first)
}
// if (a.created && b.created) {
// const dateA = parseISO(a.created);
// const dateB = parseISO(b.created);
// return compareDesc(dateA, dateB); // Descending order (latest first)
// }
// Handle cases where created date might be missing
if (a.created && !b.created) return -1;
if (!a.created && b.created) return 1;
// // Handle cases where created date might be missing
// if (a.created && !b.created) return -1;
// if (!a.created && b.created) return 1;
return 0;
});