Skip to content

Commit

Permalink
show always 10 categories tops
Browse files Browse the repository at this point in the history
  • Loading branch information
satellitestudiodesign committed Aug 28, 2024
1 parent f5277d0 commit fd27281
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const selectVesselGroupReportVesselsGraphDataGrouped = createSelector(
)
break
}
return Object.entries(vesselsGrouped)
const orderedGroups = Object.entries(vesselsGrouped)
.map(([key, value]) => ({
name: key,
value: (value as any[]).length,
Expand All @@ -40,5 +40,19 @@ export const selectVesselGroupReportVesselsGraphDataGrouped = createSelector(
}
return b.value - a.value
})

if (orderedGroups.length <= 9) {
return orderedGroups
}
const firstTen = orderedGroups.slice(0, 9)
const other = orderedGroups.slice(9)

return [
...firstTen,
{
name: OTHER_CATEGORY_LABEL,
value: other.reduce((acc, group) => acc + group.value, 0),
},
]
}
)

0 comments on commit fd27281

Please sign in to comment.