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 1 commit
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
30 changes: 23 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,18 @@ 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 name
if (isActiveComparison === 0) {
return a.name.localeCompare(b.name);
}

// Otherwise, return the comparison result of isActive
return isActiveComparison;
}) || [];
Udit-takkar marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Author

@Udit-takkar Udit-takkar Jul 6, 2024

Choose a reason for hiding this comment

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

this would first sort rounds based on isActive prop and then if both have same isActive value it would display the most recent one first


const isRecurringSelected = projectDonationSwiperState.isRecurringSelected;
const selectedQF = projectDonationSwiperState.selectedQF;
Expand Down Expand Up @@ -103,11 +112,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