import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/Components/ui/table"; import { Button } from "@/Components/ui/button"; import { Badge } from "@/Components/ui/badge"; import { Pencil, Trash2, ArrowUpDown, ArrowUp, ArrowDown } from "lucide-react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/Components/ui/alert-dialog"; import { Can } from "@/Components/Permission/Can"; import type { Product } from "@/Pages/Product/Index"; interface ProductTableProps { products: Product[]; onEdit: (product: Product) => void; onDelete: (id: number) => void; startIndex: number; sortField: string | null; sortDirection: "asc" | "desc" | null; onSort: (field: string) => void; } export default function ProductTable({ products, onEdit, onDelete, startIndex, sortField, sortDirection, onSort, }: ProductTableProps) { // const [barcodeDialogOpen, setBarcodeDialogOpen] = useState(false); // const [selectedProduct, setSelectedProduct] = useState(null); const SortIcon = ({ field }: { field: string }) => { if (sortField !== field) { return ; } if (sortDirection === "asc") { return ; } if (sortDirection === "desc") { return ; } return ; }; // 查看條碼 /* const handleViewBarcode = (product: Product) => { setSelectedProduct(product); setBarcodeDialogOpen(true); }; */ return ( <>
# 換算率 操作 {products.length === 0 ? ( 無符合條件的商品資料 ) : ( products.map((product, index) => ( {startIndex + index} {product.code}
{product.name} {product.brand && {product.brand}}
{product.category?.name || '-'} {product.base_unit?.name || '-'} {product.large_unit ? ( 1 {product.large_unit?.name} = {Number(product.conversion_rate)} {product.base_unit?.name} ) : ( '-' )}
{/* */} 確認刪除 確定要刪除「{product.name}」嗎?此操作無法復原。 取消 onDelete(product.id)} className="bg-red-600 hover:bg-red-700" > 刪除
)) )}
{/* 條碼查看對話框 - Temporarily disabled */} {/* {selectedProduct && ( )} */} ); }