Files
arjmand-pharmacy/components/ui/ProductCard.tsx
T
Alireza HassaniandCursor 66e604c426 Connect the storefront to Meshkee catalog, blogs, and static image slots.
Wire homepage specials, product/blog pages, instant search, and the customer portal so the live pharmacy site can be managed from the dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-19 23:51:41 +03:30

57 lines
2.3 KiB
TypeScript

import Link from "next/link";
import { ShoppingBag } from "lucide-react";
import { Placeholder } from "@/components/Placeholder";
import { faDigits, formatPrice } from "@/lib/format";
import type { Product } from "@/lib/data";
export function ProductCard({ product }: { product: Product }) {
const href = product.href ?? `/products/${encodeURIComponent(product.id)}`;
return (
<article className="group flex h-full flex-col rounded-2xl bg-white p-3">
<Link href={href} className="relative overflow-hidden rounded-xl bg-sky">
{product.discount ? (
<span className="absolute top-2 right-2 z-10 rounded-md bg-sale px-1.5 py-0.5 text-[11px] font-bold text-white">
{faDigits(product.discount)}٪
</span>
) : null}
<Placeholder src={product.image} fallbackSrc="/placeholders/product.svg" className="aspect-square w-full object-cover transition group-hover:scale-[1.03]" />
</Link>
{product.brand ? (
<p className="font-latin mt-3 text-[11px] tracking-wide text-primary">{product.brand}</p>
) : (
<p className="mt-3 h-[16px]" />
)}
<h3 className="mt-1 line-clamp-2 min-h-[40px] text-[13px] leading-5 text-ink">
<Link href={href}>{product.title}</Link>
</h3>
<div className="mt-auto pt-3">
{product.oldPrice ? (
<p className="text-[11px] text-muted line-through">{formatPrice(product.oldPrice)} تومان</p>
) : (
<p className="h-[16px]" />
)}
<div className="mt-1 flex items-end justify-between gap-2">
<p className="text-[14px] font-bold text-navy">
{product.price != null ? (
<>
{formatPrice(product.price)}
<span className="mr-1 text-[11px] font-medium text-muted">تومان</span>
</>
) : (
<span className="text-[12px] font-medium text-muted">تماس بگیرید</span>
)}
</p>
<Link
href={href}
className="grid size-9 place-items-center rounded-xl bg-primary text-white transition hover:bg-primary-hover"
aria-label="مشاهده محصول"
>
<ShoppingBag className="size-4" />
</Link>
</div>
</div>
</article>
);
}