From a08aa8197886f77dbd144fabb466204543d02f70 Mon Sep 17 00:00:00 2001 From: Joseph Chrzan Date: Thu, 26 Sep 2024 15:02:54 -0400 Subject: [PATCH] update sorting logic (#78) --- .../elements/plan-manager/CheckoutDialog.tsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/components/src/components/elements/plan-manager/CheckoutDialog.tsx b/components/src/components/elements/plan-manager/CheckoutDialog.tsx index 3ae19ea6..d03e63a9 100644 --- a/components/src/components/elements/plan-manager/CheckoutDialog.tsx +++ b/components/src/components/elements/plan-manager/CheckoutDialog.tsx @@ -408,20 +408,18 @@ export const CheckoutDialog = () => { {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;