"use client"; import { Crown, Package, Sparkles } from "lucide-react"; import type { CatalogItemData } from "@/components/admin/catalog/catalog-items-table/types"; import { getPointsLabel } from "@/components/admin/catalog/catalog-items-table/types"; import { CurrencyIcon, currencyKindFromPointsType, } from "@/components/shared/currency-icon"; import { Badge } from "@/components/ui/badge"; import { getHabboCdnIconUrl, getLocalIconUrl } from "@/lib/furni/classname"; import { cn } from "@/lib/utils"; /** Grid + tile sizing per page layout, shared by shop previews. */ export function getShopGridClass(layout: string): string { switch (layout) { case "spaces_new": return "grid-cols-2 sm:grid-cols-3 md:grid-cols-4"; case "frontpage": return "grid-cols-1 sm:grid-cols-2 md:grid-cols-3"; case "single_bundle": case "room_bundle": return "grid-cols-1 sm:grid-cols-2"; case "pets": case "pets2": case "pets3": return "grid-cols-2 sm:grid-cols-3 md:grid-cols-4"; default: return "grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5"; } } export function getShopTileSize(layout: string): number { switch (layout) { case "frontpage": case "single_bundle": case "room_bundle": return 140; case "spaces_new": return 110; default: return 96; } } export function parseFirstItemId(itemIds: string): number | null { if (!itemIds) return null; const first = itemIds.split(";")[0]?.trim(); const n = parseInt(first, 10); return Number.isNaN(n) ? null : n; } interface ShopTileProps { item: CatalogItemData; furni?: { classname: string; revision: number } | null; /** Pixel height of the icon area. Defaults to a small standard tile. */ iconHeight?: number; canEdit?: boolean; onClick?: (item: CatalogItemData) => void; } /** One purchasable offer tile exactly as it appears in the shop. */ export function ShopTile({ item, furni, iconHeight = 96, canEdit, onClick, }: ShopTileProps) { const points = getPointsLabel(item.pointsType); const isClub = item.clubOnly === "1"; const isOffer = item.haveOffer === "1" && item.offerId > 0; const isLimited = item.limitedStack > 0; return ( ); } // ── Shop tile furni icon (resizable) ──────────────────────────── export function ShopFurniIcon({ classname, revision, size, }: { classname: string; revision: number; size: number; }) { if (!classname) { return ( ); } const primary = getLocalIconUrl(classname); function handleError(e: React.SyntheticEvent) { const img = e.target as HTMLImageElement; if (!img.dataset.fallback && revision > 0) { img.dataset.fallback = "cdn"; img.src = getHabboCdnIconUrl(classname, revision); } else { img.style.opacity = "0"; } } return ( {classname} ); }