From 9e883fda0e1371491c3216ccbe11e50f45a4d500 Mon Sep 17 00:00:00 2001 From: Udit Takkar Date: Sun, 7 Jul 2024 00:21:35 +0530 Subject: [PATCH 1/2] chore: sort alphabetically --- .../projectDonations/QfRoundSelector.tsx | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/components/views/project/projectDonations/QfRoundSelector.tsx b/src/components/views/project/projectDonations/QfRoundSelector.tsx index 9f6feba4ea..5705679253 100644 --- a/src/components/views/project/projectDonations/QfRoundSelector.tsx +++ b/src/components/views/project/projectDonations/QfRoundSelector.tsx @@ -37,9 +37,18 @@ export const QfRoundSelector: FC = ({ const navigationNextRef = useRef(null); const sortedRounds = - projectData?.qfRounds?.sort( - (a, b) => Number(b.isActive) - Number(a.isActive), - ) || []; + projectData?.qfRounds?.sort((a, b) => { + // First, compare by isActive + const isActiveComparison = Number(b.isActive) - Number(a.isActive); + + // If isActive values are the same, compare by name + if (isActiveComparison === 0) { + return a.name.localeCompare(b.name); + } + + // Otherwise, return the comparison result of isActive + return isActiveComparison; + }) || []; const isRecurringSelected = projectDonationSwiperState.isRecurringSelected; const selectedQF = projectDonationSwiperState.selectedQF; @@ -103,11 +112,18 @@ export const QfRoundSelector: FC = ({ }} $isSelected={isRecurringSelected === true} > - {(projectDonationSwiperState.selectedQF === null) === - null ? ( - Recurring Donations + {projectDonationSwiperState.selectedQF === null ? ( + + {formatMessage({ + id: 'label.recurring_donation', + })} + ) : ( -

Recurring Donations

+

+ {formatMessage({ + id: 'label.recurring_donation', + })} +

)} From b3548ff1e0ebff8c942de5e94cc4c08a051a66b0 Mon Sep 17 00:00:00 2001 From: Udit Takkar Date: Sun, 7 Jul 2024 00:38:39 +0530 Subject: [PATCH 2/2] chore: sort by date --- .../views/project/projectDonations/QfRoundSelector.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/views/project/projectDonations/QfRoundSelector.tsx b/src/components/views/project/projectDonations/QfRoundSelector.tsx index 5705679253..d054362576 100644 --- a/src/components/views/project/projectDonations/QfRoundSelector.tsx +++ b/src/components/views/project/projectDonations/QfRoundSelector.tsx @@ -41,9 +41,12 @@ export const QfRoundSelector: FC = ({ // First, compare by isActive const isActiveComparison = Number(b.isActive) - Number(a.isActive); - // If isActive values are the same, compare by name + // If isActive values are the same, compare by beginDate (most recent first) if (isActiveComparison === 0) { - return a.name.localeCompare(b.name); + return ( + new Date(b.beginDate).getTime() - + new Date(a.beginDate).getTime() + ); } // Otherwise, return the comparison result of isActive