"use client"; import { Coins, DollarSign, MapPin, Package, User } from "lucide-react"; import Image from "next/image"; import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import type { Chat } from "@/lib/hooks/use-chat"; interface ChatHeaderProps { chat: Chat; currentUserId: number; } export function ChatHeader({ chat, currentUserId }: ChatHeaderProps) { const listing = chat.listing_cache; const otherUser = chat.buyer_id === currentUserId ? chat.seller_cache : chat.buyer_cache; const [imageError, setImageError] = useState(false); const formatPrice = ( price: number | null | undefined, type: "pix" | "tc" | "gp", ): string => { if (price === null || price === undefined) return "N/A"; if (type === "pix") { return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL", }).format(price); } if (type === "tc") { return `${price.toLocaleString("pt-BR")} TC`; } if (type === "gp") { const gold = price / 1000000; if (gold >= 1) { return `${gold.toFixed(2)}kk`; } return `${price.toLocaleString("pt-BR")} gp`; } return price.toLocaleString("pt-BR"); }; return (