"use client"; import Link from "next/link"; import type { CommercialProduct } from "../types"; import { resolveProductLaunchUrl } from "../types"; import { Button } from "@/components/ui"; import { FeatureLock } from "./FeatureLock"; import { pushRecent } from "../launcher-prefs"; import { enumLabel } from "../presentation"; export function ProductCard({ product, recommendationScore, tenantId, favorite, pinned, onToggleFavorite, onTogglePinned, }: { product: CommercialProduct; recommendationScore?: number; tenantId?: string; favorite?: boolean; pinned?: boolean; onToggleFavorite?: () => void; onTogglePinned?: () => void; }) { const visibilityLocked = product.visibility === "hidden" || product.status === "inactive"; const launchUrl = resolveProductLaunchUrl(product); const strategy = product.launch_strategy || "route"; const requiredCap = product.required_capabilities?.[0]; const setupHref = `/setup/${encodeURIComponent(product.product_code)}`; const markRecent = () => { pushRecent(product.product_code); }; const launchButton = launchUrl && !visibilityLocked && strategy !== "disabled" ? ( strategy === "external" ? ( ) : ( ) ) : null; return (
{product.icon || (product.display_name?.charAt(0) ?? "P")}

{product.display_name}

{product.category ? ( {enumLabel(product.category)} ) : null} {typeof recommendationScore === "number" ? ( پیشنهاد مناسب شما ) : null}
{product.description ? (

{product.description}

) : null} {product.trial_eligible ?

امکان استفاده آزمایشی

: null}
{onToggleFavorite ? ( ) : null} {onTogglePinned ? ( ) : null} راه‌اندازی
{launchButton ? (
{tenantId && requiredCap ? ( قفل — ارتقا لازم } > {launchButton} ) : ( launchButton )}
) : (
)}
); }