Skip to content

Commit

Permalink
Update CustomCommuneSort.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ericboucher committed Jul 22, 2024
1 parent 0fe5fa4 commit 95d02c3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions apps/frontend/components/DisasterTable/CustomCommuneSort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,15 @@ export const createCustomComparator =

// Compare district data
if (parentData1.districtData !== parentData2.districtData) {
const result =
(parentData2.districtData ?? 0) - (parentData1.districtData ?? 0);

// Handle edge case for districtData
if (row1.id.length === 2 && !(row2.id.length === 2)) {
if (parentData1.isProvince && !parentData2.isProvince) {
return -1; // Province rows should come before non-province rows
}
if (!(row1.id.length === 2) && row2.id.length === 2) {
if (!parentData1.isProvince && parentData2.isProvince) {
return 1; // Non-province rows should come after province rows
}

return result;
return (parentData2.districtData ?? 0) - (parentData1.districtData ?? 0);
}

// Compare row values
Expand Down

0 comments on commit 95d02c3

Please sign in to comment.