import { Link, type LinkProps } from "@remix-run/react"; import { BadgeDollarSign, User2 } from "lucide-react"; import { forwardRef } from "react"; import { useGetProjectToken } from "~/services/projects/get-user-token"; import type { Proyek } from "~/types/api/proyek"; import { StatusProject } from "~/types/constants/status-project"; import toRupiah from "~/utils/to-rupiah"; import { Badge } from "../ui/badge"; import { Progress } from "../ui/progress"; import BorderedCard from "./bordered-card"; export interface ProjectCardProps extends LinkProps { data: Proyek | undefined; } const ProjectCard = forwardRef( ({ data, to, ...props }, ref) => { const { data: tokenData } = useGetProjectToken(data?.id); const tokenValue = () => { const collectedTokens = tokenData?.jumlah_token ?? 0; const totalTokens = data?.jumlah_koin ? Number.parseInt(data.jumlah_koin, 10) : 0; if (totalTokens === 0) return 0; const percentage = (collectedTokens / totalTokens) * 100; return Math.min(100, Math.max(0, percentage)); }; const getTokenPriceTier = (price: number) => { if (price >= 10000000) return "text-blue-500 font-bold"; if (price >= 5000000) return "text-green-500 font-bold"; if (price >= 1000000) return "text-yellow-500 font-bold"; if (price >= 100000) return "text-gray-400 font-bold"; return "text-gray-500"; }; const getTokenPriceLabel = (price: number) => { if (price >= 10000000) return (
Diamond Tier
); if (price >= 5000000) return (
Emerald Tier
); if (price >= 1000000) return (
Gold Tier
); if (price >= 100000) return (
); return ""; }; return (
{data && ( {data.status} )}
{data && ( <>

{data.judul}

{data.user?.nama}

Harga PerToken: {toRupiah(data.harga_per_unit?.toString() ?? "0")}

{getTokenPriceLabel(Number(data.harga_per_unit))}
)}

Terkumpul

{tokenData?.jumlah_token ?? 0} Token

Sisa Hari

{0} Hari

); }, ); ProjectCard.displayName = "ProjectCard"; export default ProjectCard;