"use client";
import {
ChevronDown,
ChevronUp,
Github,
Globe,
Heart,
Star,
Terminal,
} from "lucide-react";
import Image from "next/image";
import { useState } from "react";
import {
filterVisibleSponsors,
formatSponsorUrl,
getSponsorUrl,
isSpecialSponsor,
shouldShowLifetimeTotal,
sortSpecialSponsors,
} from "@/lib/sponsor-utils";
import type { SponsorsData } from "@/lib/types";
export default function SponsorsSection({
sponsorsData,
}: {
sponsorsData: SponsorsData;
}) {
const [showPastSponsors, setShowPastSponsors] = useState(false);
const allCurrentSponsors = [
...sponsorsData.specialSponsors,
...sponsorsData.sponsors,
];
const visibleSponsors = filterVisibleSponsors(allCurrentSponsors);
const pastSponsors = sponsorsData.pastSponsors;
const specialSponsors = sortSpecialSponsors(sponsorsData.specialSponsors);
return (
SPONSORS_DATABASE.JSON
[{visibleSponsors.length} RECORDS]
{visibleSponsors.length === 0 ? (
NO_SPONSORS_FOUND.NULL
$
Be the first to support this project!
) : (
{specialSponsors.length > 0 && (
{specialSponsors.map((entry, index) => {
const sponsorUrl = getSponsorUrl(entry);
return (
SPECIAL
•
{entry.sinceWhen.toUpperCase()}
{entry.name}
{shouldShowLifetimeTotal(entry) ? (
<>
{entry.tierName && (
{entry.tierName}
)}
Total: {entry.formattedAmount}
>
) : (
{entry.tierName}
)}
);
})}
)}
{sponsorsData.sponsors.length > 0 && (
{sponsorsData.sponsors.map((entry, index) => {
const sponsorUrl = getSponsorUrl(entry);
return (
▶
{entry.sinceWhen.toUpperCase()}
{entry.name}
{shouldShowLifetimeTotal(entry) ? (
<>
{entry.tierName && (
{entry.tierName}
)}
Total: {entry.formattedAmount}
>
) : (
{entry.tierName}
)}
);
})}
)}
{pastSponsors.length > 0 && (
{showPastSponsors && (
{pastSponsors.map((entry, index) => {
const wasSpecial = isSpecialSponsor(entry);
const sponsorUrl = getSponsorUrl(entry);
return (
{wasSpecial ? (
) : (
◆
)}
{wasSpecial && SPECIAL}
{wasSpecial && •}
{entry.sinceWhen.toUpperCase()}
{entry.name}
{shouldShowLifetimeTotal(entry) ? (
<>
{entry.tierName && (
{entry.tierName}
)}
Total: {entry.formattedAmount}
>
) : (
{entry.tierName}
)}
);
})}
)}
)}
)}
);
}