Skip to content

Commit

Permalink
Merge pull request #4813 from Giveth/sort-rounds-in-project-page
Browse files Browse the repository at this point in the history
Sort rounds in project page
  • Loading branch information
HrithikSampson authored Oct 4, 2024
2 parents 92e7be9 + 88a190f commit 58ebadf
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ 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: IQFRound, b: IQFRound) => {
const activeFirstCompare = Number(b.isActive) - Number(a.isActive);
if (activeFirstCompare === 0) {
return new Date(b.beginDate) > new Date(a.beginDate) ? 1 : -1;
}
return activeFirstCompare;
}) || [];

const isRecurringSelected = projectDonationSwiperState.isRecurringSelected;
const selectedQF = projectDonationSwiperState.selectedQF;
Expand Down

0 comments on commit 58ebadf

Please sign in to comment.