import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import type { Auction } from "@shared/schema"; interface AuctionCardProps { auction: Auction; } export default function AuctionCard({ auction }: AuctionCardProps) { const formatPrice = (price: string) => { const num = parseFloat(price); return `$${num.toLocaleString()}`; }; const getTimeRemaining = (endDate: string | Date) => { const end = new Date(endDate); const now = new Date(); const diff = end.getTime() - now.getTime(); if (diff <= 0) return "Ended"; const days = Math.floor(diff / (1000 * 60 * 60 * 24)); const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); if (days > 0) return `${days}d ${hours}h`; if (hours > 0) return `${hours}h ${minutes}m`; return `${minutes}m`; }; const getStatusBadge = () => { const timeRemaining = getTimeRemaining(auction.endDate); if (timeRemaining === "Ended") return { text: "Ended", variant: "secondary" as const }; const end = new Date(auction.endDate); const now = new Date(); const hoursLeft = (end.getTime() - now.getTime()) / (1000 * 60 * 60); if (hoursLeft <= 3) return { text: "Ending Soon", variant: "destructive" as const }; return { text: "Active", variant: "default" as const }; }; const status = getStatusBadge(); return (

{auction.title}

{auction.description}

{status.text}
Current Bid: {formatPrice(auction.currentBid || "0")}
Quality Score: {auction.qualityScore || 0}/100
Time Remaining: {getTimeRemaining(auction.endDate)}
); }