Skip to content

Commit

Permalink
update sorting logic (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenub authored Sep 26, 2024
1 parent 01f6b9a commit a08aa81
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions components/src/components/elements/plan-manager/CheckoutDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,20 +408,18 @@ export const CheckoutDialog = () => {
<Flex $flexWrap="wrap" $gap="1rem" $flexGrow="1">
{availablePlans
.sort((a, b) => {
if (
planPeriod === "year" &&
a.yearlyPrice &&
b.yearlyPrice
) {
return a.yearlyPrice?.price - b.yearlyPrice?.price;
if (planPeriod === "year") {
return (
(a.yearlyPrice?.price ?? 0) -
(b.yearlyPrice?.price ?? 0)
);
}

if (
planPeriod === "month" &&
a.monthlyPrice &&
b.monthlyPrice
) {
return a.monthlyPrice.price - b.monthlyPrice.price;
if (planPeriod === "month") {
return (
(a.monthlyPrice?.price ?? 0) -
(b.monthlyPrice?.price ?? 0)
);
}

return 0;
Expand Down

0 comments on commit a08aa81

Please sign in to comment.