"use client"; import { Crown, Image as ImageIcon, Package, Sparkles } from "lucide-react"; import { type CatalogItemData, getPointsLabel, } from "@/app/admin/catalog/[id]/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"; interface ItemsShopPreviewProps { items: CatalogItemData[]; furniRevisionMap: Record; layout: string; canEdit: boolean; onItemClick?: (item: CatalogItemData) => void; } export function ItemsShopPreview({ items, furniRevisionMap, layout, canEdit, onItemClick, }: ItemsShopPreviewProps) { if (items.length === 0) { return (

No items in this page yet

); } const gridClass = getGridClass(layout); const tileSize = getTileSize(layout); return (
Shop preview · {layout} {items.length} items
{items.map((item) => { const firstId = parseFirstItemId(item.itemIds); const furni = firstId != null ? furniRevisionMap[firstId] : undefined; const points = getPointsLabel(item.pointsType); const isClub = item.clubOnly === "1"; const isOffer = item.haveOffer === "1" && item.offerId > 0; return ( ); })}
); } // ── Helpers ───────────────────────────────────────────────────── 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; } function getGridClass(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"; } } function getTileSize(layout: string): number { switch (layout) { case "frontpage": case "single_bundle": case "room_bundle": return 140; case "spaces_new": return 110; default: return 96; } } // ── Shop tile furni icon (resizable) ──────────────────────────── 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 ( // eslint-disable-next-line @next/next/no-img-element {classname} ); }