Fix sorting shit in recap
This commit is contained in:
@@ -30,7 +30,21 @@ const RecapPopover: React.FC<RecapPopoverProps> = ({
|
||||
value: calculateJobValue(job)
|
||||
}))
|
||||
.filter(({ value }) => value !== 0)
|
||||
.sort((a, b) => sortDescending ? Math.abs(b.value) - Math.abs(a.value) : Math.abs(a.value) - Math.abs(b.value));
|
||||
.sort((a, b) => {
|
||||
if (sortDescending) {
|
||||
// For descending: negative values first, then positive values
|
||||
// Within each group, sort by magnitude
|
||||
if (a.value < 0 && b.value >= 0) return -1; // a (negative) comes first
|
||||
if (a.value >= 0 && b.value < 0) return 1; // b (negative) comes first
|
||||
return Math.abs(b.value) - Math.abs(a.value); // same sign, sort by magnitude
|
||||
} else {
|
||||
// For ascending: positive values first, then negative values
|
||||
// Within each group, sort by magnitude
|
||||
if (a.value >= 0 && b.value < 0) return -1; // a (positive) comes first
|
||||
if (a.value < 0 && b.value >= 0) return 1; // b (positive) comes first
|
||||
return Math.abs(a.value) - Math.abs(b.value); // same sign, sort by magnitude
|
||||
}
|
||||
});
|
||||
|
||||
const handleJobClick = (jobId: string) => {
|
||||
navigate(`/${jobId}`);
|
||||
|
Reference in New Issue
Block a user