"use client"; import { TibiaItem } from "@/types/item"; import { MagicCard } from "@/components/ui/magic-card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { PriceDisplay } from "@/components/ui/price-display"; import { useTranslations } from "next-intl"; import { TrendingUp, TrendingDown, Sword, Shield, Weight, Heart, Star, Clock, Coins, ArrowUp, ArrowDown, Minus, Zap, Flame, Snowflake, Zap as Energy, Skull, Cross, } from "lucide-react"; import { useState } from "react"; import { getRarityColor, getRarityBgColor, getRarityGlow, } from "@/lib/currency-utils"; interface ItemCardProps { item: TibiaItem; } export function ItemCard({ item }: ItemCardProps) { const t = useTranslations("home.item"); const [isFavorited, setIsFavorited] = useState(false); const [isHovered, setIsHovered] = useState(false); const rarityColors = { common: "bg-gray-500", uncommon: "bg-green-500", rare: "bg-blue-500", epic: "bg-purple-500", legendary: "bg-orange-500", }; const categoryIcons = { weapon: Sword, armor: Shield, helmet: Shield, legs: Shield, boots: Shield, shield: Shield, amulet: "💎", ring: "💍", potion: "🧪", rune: "📜", tool: "🔧", ammunition: "🏹", other: "📦", }; const CategoryIcon = categoryIcons[item.category]; // Calcular diferença percentual entre compra e venda const priceDifference = ((item.price.buy - item.price.sell) / item.price.sell) * 100; const isHotDeal = priceDifference > 20; // Hot deal se diferença > 20% // Determinar tendência de preço const getPriceTrend = () => { if (item.priceHistory.highest > item.priceHistory.average * 1.1) return "up"; if (item.priceHistory.lowest < item.priceHistory.average * 0.9) return "down"; return "stable"; }; const trend = getPriceTrend(); const TrendIcon = trend === "up" ? ArrowUp : trend === "down" ? ArrowDown : Minus; const trendColor = trend === "up" ? "text-green-500" : trend === "down" ? "text-red-500" : "text-gray-500"; return (
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} > {/* Header com ícone e badge de raridade */}
{/* Badge de raridade com glow */} {item.rarity} {/* Botão de favorito */} {/* Hot Deal Badge */} {isHotDeal && ( 🔥 Hot Deal )} {/* Ícone do item */}
{typeof CategoryIcon === "string" ? ( CategoryIcon ) : ( )}
{/* Conteúdo do card */}
{/* Nome do item */}

{item.name}

{/* Timestamp */}
Atualizado há 5 min
{/* Estatísticas agrupadas */} {item.stats && (
{item.stats.attack && (
⚔️ {item.stats.attack} ATK
)} {item.stats.defense && (
🛡️ {item.stats.defense} DEF
)} {item.stats.armor && (
🛡️ {item.stats.armor} ARM
)}
{/* Proteções elementais */} {item.protections && (
{item.protections.fire && (
🔥 Fire +{item.protections.fire}%
)} {item.protections.ice && (
❄️ Ice +{item.protections.ice}%
)} {item.protections.energy && (
⚡ Energy +{item.protections.energy}%
)}
)} {/* Requisitos */} {item.requirements && (
{item.requirements.level && (
📊 Level {item.requirements.level}+
)} {item.requirements.vocation && (
👤 Best for {item.requirements.vocation}
)}
)} {item.stats.weight && (
⚖️ {item.stats.weight} oz
)}
)} {/* Divisor visual */}
{/* Preços com ícones e formatação melhorada */}
{t("buyPrice")}
{t("sellPrice")}
{/* Diferença percentual */}
0 ? "text-green-600" : "text-red-600" }`} > {priceDifference > 0 ? "+" : ""} {priceDifference.toFixed(1)}% diferença
{/* Divisor visual */}
{/* Histórico de preço com sparkline */}
{t("priceHistory")}
{trend}
{t("highest")}
🪙 {item.priceHistory.highest.toLocaleString()} gp
{t("lowest")}
🪙 {item.priceHistory.lowest.toLocaleString()} gp
{t("average")}
🪙 {item.priceHistory.average.toLocaleString()} gp
{/* Botões de ação */}
); }