From 7c7db0fc09fb7827619927a2e8274b07837a72b3 Mon Sep 17 00:00:00 2001 From: g Date: Mon, 12 Jan 2026 06:54:28 +0000 Subject: [PATCH] Update product-table.tsx --- components/tables/product-table.tsx | 240 +++++++++++++++++----------- 1 file changed, 147 insertions(+), 93 deletions(-) diff --git a/components/tables/product-table.tsx b/components/tables/product-table.tsx index dcdbb3e..0630f36 100644 --- a/components/tables/product-table.tsx +++ b/components/tables/product-table.tsx @@ -1,5 +1,4 @@ -import { - Table, +Table, TableBody, TableCell, TableHead, @@ -14,11 +13,15 @@ import { AlertCircle, Calculator, Copy, + PackageOffset, + Archive } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Product } from "@/models/products"; import { Badge } from "@/components/ui/badge"; import { Switch } from "@/components/ui/switch"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { motion, AnimatePresence } from "framer-motion"; interface ProductTableProps { products: Product[]; @@ -68,35 +71,53 @@ const ProductTable = ({ } }; - const renderProductRow = (product: Product, isDisabled: boolean = false) => ( - ( + - -
{product.name}
-
- {getCategoryNameById(product.category)} + +
+
+ {product.image ? ( + {product.name} + ) : ( + {product.name.charAt(0).toUpperCase()} + )} +
+
+
{product.name}
+
+ {getCategoryNameById(product.category)} +
+
- {getCategoryNameById(product.category)} + + {getCategoryNameById(product.category)} + - + {product.unitType} {product.stockTracking ? ( -
+
{getStockIcon(product)} - - {product.currentStock !== undefined ? product.currentStock : 0}{" "} - {product.unitType} + + {product.currentStock !== undefined ? product.currentStock : 0}
) : ( - - Not Tracked + + Unlimited )} @@ -106,57 +127,61 @@ const ProductTable = ({ onCheckedChange={(checked) => onToggleEnabled(product._id as string, checked) } + className="data-[state=checked]:bg-primary" /> - - {onProfitAnalysis && ( + +
+ {onProfitAnalysis && ( + + )} + {onClone && ( + + )} - )} - {onClone && ( - )} - - +
- + ); const renderTableHeader = () => ( - - + + Product Category @@ -166,57 +191,86 @@ const ProductTable = ({ Enabled - Actions + Actions ); return ( -
+
{/* Enabled Products Table */} -
- - {renderTableHeader()} - - {loading ? ( - Array.from({ length: 1 }).map((_, index) => ( - - Loading... - Loading... - Loading... - Loading... - Loading... - Loading... - - )) - ) : sortedEnabledProducts.length > 0 ? ( - sortedEnabledProducts.map((product) => renderProductRow(product)) - ) : ( - - - No enabled products found. - - - )} - -
-
+ + + + + Active Products + + {sortedEnabledProducts.length} + + + + +
+ + {renderTableHeader()} + + + {loading ? ( + + + Loading products... + + + ) : sortedEnabledProducts.length > 0 ? ( + sortedEnabledProducts.map((product, index) => renderProductRow(product, index)) + ) : ( + + +
+ +

No active products found

+
+
+
+ )} +
+
+
+
+
+
{/* Disabled Products Section */} {!loading && disabledProducts.length > 0 && ( -
- - {renderTableHeader()} - - {sortedDisabledProducts.map((product) => - renderProductRow(product, true), - )} - -
-
+ + + + + Archived / Disabled + + {sortedDisabledProducts.length} + + + + +
+ + {renderTableHeader()} + + + {sortedDisabledProducts.map((product, index) => + renderProductRow(product, index, true), + )} + + +
+
+
+
)}
); + }; export default ProductTable;