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',
title: 'قیمت',
render: (item: Product) => {
return formatPrice(item.price)
}
},
{
key: 'inventory',
title: 'موجودی',
render: (item: Product) => {
const inv = item.inventory
if (!inv) return '-'
const availableStock = inv.availableStock
const totalStock = inv.totalStock
return (
<div className='flex flex-col gap-1'>
<span className='text-sm'>
{availableStock} / {totalStock}
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)
const minPrice = Math.min(...prices)
const maxPrice = Math.max(...prices)
if (minPrice === maxPrice) return formatPrice(minPrice)
return (
<span>
از {formatPrice(minPrice)} تا {formatPrice(maxPrice)}
</span>
{availableStock === 0 && (
<span className='text-xs text-red-500'>ناموجود</span>
)}
</div>
)
)
}
return formatPrice(item.price)
}
},
{