"use client"; import { Clock, Coins, Heart, Shield, Sword } from "lucide-react"; import { useTranslations } from "next-intl"; import { useState } from "react"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { PriceDisplay } from "@/components/ui/price-display"; import type { MarketOffer } from "@/types/item"; interface OfferCardProps { offer: MarketOffer; } export function OfferCard({ offer }: OfferCardProps) { const t = useTranslations("home.stats"); const tButtons = useTranslations("home.buttons"); const [isFavorited, setIsFavorited] = useState(false); const [_isHovered, setIsHovered] = useState(false); const formatTimeAgo = (timestamp: Date) => { const now = new Date(); const diff = now.getTime() - timestamp.getTime(); const minutes = Math.floor(diff / (1000 * 60)); if (minutes < 1) return "Agora"; if (minutes < 60) return `há ${minutes} ${t("minutes")}`; const hours = Math.floor(minutes / 60); if (hours < 24) return `há ${hours} ${t("hours")}`; const days = Math.floor(hours / 24); return `há ${days} dias`; }; const getInitials = (name: string) => { return name .split(" ") .map((word) => word[0]) .join("") .toUpperCase() .slice(0, 2); }; const getCategoryIcon = (category: string) => { switch (category) { case "weapon": return ; case "armor": return ; default: return "📦"; } }; const getRarityColor = (rarity: string) => { switch (rarity) { case "common": return "bg-gray-500"; case "uncommon": return "bg-green-500"; case "rare": return "bg-blue-500"; case "epic": return "bg-purple-500"; case "legendary": return "bg-orange-500"; default: return "bg-gray-500"; } }; const isHotDeal = offer.price < offer.item.priceHistory.average * 0.8; const isNewOffer = Date.now() - offer.timestamp.getTime() < 1000 * 60 * 30; // 30 min return (
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} > {/* Badges de status */}
{isNewOffer && ( ⭐ {t("status.new")} )} {isHotDeal && ( 🔥 {t("status.hotDeal")} )}
{/* Botão de favorito */}
{/* Ícone do item com raridade */}
{getCategoryIcon(offer.item.category)}
{offer.item.rarity}
{/* Informações do item */}

{offer.item.name}

{getInitials(offer.seller)} {offer.seller}
{formatTimeAgo(offer.timestamp)}
{/* Estatísticas do item */} {offer.item.stats && (
{offer.item.stats.attack && (
{offer.item.stats.attack} ATK
)} {offer.item.stats.defense && (
{offer.item.stats.defense} DEF
)} {offer.item.stats.armor && (
{offer.item.stats.armor} ARM
)}
)}
{/* Preço e ações */}
Preço

{offer.item.stackable ? `Stack: ${offer.quantity}x` : `Qtd: ${offer.quantity}`} {offer.item.stackable && offer.quantity > 1 && ( {Math.round(offer.price / offer.quantity).toLocaleString()}{" "} gp cada )}

{offer.type === "buy" ? "Comprando" : "Vendendo"}
); }