Skip to content

Commit

Permalink
chore: sort alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
Udit-takkar committed Jul 6, 2024
1 parent 329649f commit 9e883fd
Showing 1 changed file with 23 additions and 7 deletions.
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;
}) || [];

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',
})}
</B>
) : (
<P>Recurring Donations</P>
<P>
{formatMessage({
id: 'label.recurring_donation',
})}
</P>
)}
</TabItem>
</SwiperSlide>
Expand Down

0 comments on commit 9e883fd

Please sign in to comment.