import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Edit, Trash } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Product } from "@/models/products"; interface ProductTableProps { products: Product[]; loading: boolean; onEdit: (product: Product) => void; onDelete: (productId: string) => void; // Added onDelete prop getCategoryNameById: (categoryId: string) => string; } const ProductTable = ({ products, loading, onEdit, onDelete, getCategoryNameById }: ProductTableProps) => { return (
Product Category Unit Actions {loading ? ( Array.from({ length: 1 }).map((_, index) => ( Loading... Loading... Loading... Loading... )) ) : products.length > 0 ? ( products.map((product) => ( {product.name} {getCategoryNameById(product.category)} {/* Display category name */} {product.unitType}
)) ) : ( No products found. )}
); }; export default ProductTable;