diff --git a/apps/web/src/app/(home)/_components/sponsors-section.tsx b/apps/web/src/app/(home)/_components/sponsors-section.tsx index 1837007..833c2cc 100644 --- a/apps/web/src/app/(home)/_components/sponsors-section.tsx +++ b/apps/web/src/app/(home)/_components/sponsors-section.tsx @@ -15,7 +15,32 @@ export default function SponsorsSection() { return res.json(); }) .then((data) => { - setSponsors(Array.isArray(data) ? data : []); + const sponsorsData = Array.isArray(data) ? data : []; + + const sortedSponsors = sponsorsData.sort((a, b) => { + const getAmount = (sponsor: Sponsor) => { + if (!sponsor.isOneTime && sponsor.monthlyDollars > 0) { + return sponsor.monthlyDollars; + } + + if (sponsor.tierName) { + const match = sponsor.tierName.match(/\$(\d+(?:\.\d+)?)/); + return match ? Number.parseFloat(match[1]) : 0; + } + + return 0; + }; + + const aIsMonthly = !a.isOneTime; + const bIsMonthly = !b.isOneTime; + + if (aIsMonthly && !bIsMonthly) return -1; + if (!aIsMonthly && bIsMonthly) return 1; + + return getAmount(b) - getAmount(a); + }); + + setSponsors(sortedSponsors); setLoadingSponsors(false); }) .catch(() => {