list of products

This commit is contained in:
hamid zarghami
2026-02-09 15:18:40 +03:30
parent ba5beae0f7
commit 856ed608ac
@@ -50,27 +50,20 @@ export const getProductTableColumns = ({ onDelete, isDeleting }: GetProductTable
key: 'price', key: 'price',
title: 'قیمت', title: 'قیمت',
render: (item: Product) => { render: (item: Product) => {
return formatPrice(item.price) const variants = item.variants
} if (variants && variants.length > 0) {
}, const prices = variants.map((v) => v.price).filter((p) => p != null)
{ if (prices.length === 0) return formatPrice(item.price)
key: 'inventory', const minPrice = Math.min(...prices)
title: 'موجودی', const maxPrice = Math.max(...prices)
render: (item: Product) => { if (minPrice === maxPrice) return formatPrice(minPrice)
const inv = item.inventory return (
if (!inv) return '-' <span>
const availableStock = inv.availableStock از {formatPrice(minPrice)} تا {formatPrice(maxPrice)}
const totalStock = inv.totalStock
return (
<div className='flex flex-col gap-1'>
<span className='text-sm'>
{availableStock} / {totalStock}
</span> </span>
{availableStock === 0 && ( )
<span className='text-xs text-red-500'>ناموجود</span> }
)} return formatPrice(item.price)
</div>
)
} }
}, },
{ {