list of products
This commit is contained in:
@@ -50,28 +50,21 @@ 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
|
|
||||||
if (!inv) return '-'
|
|
||||||
const availableStock = inv.availableStock
|
|
||||||
const totalStock = inv.totalStock
|
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col gap-1'>
|
<span>
|
||||||
<span className='text-sm'>
|
از {formatPrice(minPrice)} تا {formatPrice(maxPrice)}
|
||||||
{availableStock} / {totalStock}
|
|
||||||
</span>
|
</span>
|
||||||
{availableStock === 0 && (
|
|
||||||
<span className='text-xs text-red-500'>ناموجود</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
return formatPrice(item.price)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'isActive',
|
key: 'isActive',
|
||||||
|
|||||||
Reference in New Issue
Block a user