From 856ed608acfce34d203b8765cf201bc0e2b550d0 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 9 Feb 2026 15:18:40 +0330 Subject: [PATCH] list of products --- .../components/ProductTableColumns.tsx | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/pages/product/components/ProductTableColumns.tsx b/src/pages/product/components/ProductTableColumns.tsx index 79d9107..881263c 100644 --- a/src/pages/product/components/ProductTableColumns.tsx +++ b/src/pages/product/components/ProductTableColumns.tsx @@ -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 ( -
- - {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 ( + + از {formatPrice(minPrice)} تا {formatPrice(maxPrice)} - {availableStock === 0 && ( - ناموجود - )} -
- ) + ) + } + return formatPrice(item.price) } }, {