Skip to content

Commit

Permalink
Merge pull request #256 from hiroyukikumazawa/issues/255
Browse files Browse the repository at this point in the history
Fix sort feature in GPU pricing page
  • Loading branch information
Hooman Digital authored Jun 21, 2024
2 parents f036fa9 + 8bdcb8d commit 91a6618
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/components/gpu-table/sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,32 @@ export default function Sort({
switch (sortType) {
case "Availability":
filters.modal.length > 0 ||
filters.ram.length > 0 ||
filters.interface.length > 0
filters.ram.length > 0 ||
filters.interface.length > 0
? setFilteredData((prev) =>
[...prev].sort(
(a, b) => b.availability.available - a.availability.available,
),
)
[...prev].sort(
(a, b) => b.availability.available - a.availability.available,
),
)
: setFilteredData(onTop());
break;
case "Lowest Price":
setFilteredData((prev) =>
[...prev].sort((a, b) => a.price.med - b.price.med),
[...prev].sort((a, b) => {
const aMed = a.price ? a.price.med : 0;
const bMed = b.price ? b.price.med : 0;
return aMed - bMed;
}),
);

break;
case "Highest Price":
setFilteredData((prev) =>
[...prev].sort((a, b) => b.price.med - a.price.med),
[...prev].sort((a, b) => {
const aMed = a.price ? a.price.med : 0;
const bMed = b.price ? b.price.med : 0;
return bMed - aMed;
}),
);
break;
default:
Expand Down

0 comments on commit 91a6618

Please sign in to comment.