Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sort by date #4390

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions src/components/views/project/projectDonations/QfRoundSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,21 @@ export const QfRoundSelector: FC<IQfRoundSelectorProps> = ({
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 beginDate (most recent first)
if (isActiveComparison === 0) {
return (
new Date(b.beginDate).getTime() -
new Date(a.beginDate).getTime()
);
}

// Otherwise, return the comparison result of isActive
return isActiveComparison;
}) || [];

const isRecurringSelected = projectDonationSwiperState.isRecurringSelected;
const selectedQF = projectDonationSwiperState.selectedQF;
Expand Down Expand Up @@ -103,11 +115,18 @@ export const QfRoundSelector: FC<IQfRoundSelectorProps> = ({
}}
$isSelected={isRecurringSelected === true}
>
{(projectDonationSwiperState.selectedQF === null) ===
null ? (
<B>Recurring Donations</B>
{projectDonationSwiperState.selectedQF === null ? (
<B>
{formatMessage({
id: 'label.recurring_donation',
Comment on lines +120 to +121
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n was missing here

})}
</B>
) : (
<P>Recurring Donations</P>
<P>
{formatMessage({
id: 'label.recurring_donation',
})}
</P>
)}
</TabItem>
</SwiperSlide>
Expand Down