import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/Components/ui/table"; import { Button } from "@/Components/ui/button"; import { StatusBadge } from "@/Components/shared/StatusBadge"; import { Pencil, Trash2, ArrowUpDown, ArrowUp, ArrowDown, Eye } from "lucide-react"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/Components/ui/tooltip"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/Components/ui/alert-dialog"; import { Can } from "@/Components/Permission/Can"; import { Link } from "@inertiajs/react"; import type { Product } from "@/Pages/Product/Index"; interface ProductTableProps { products: Product[]; onDelete: (id: string) => void; startIndex: number; sortField: string | null; sortDirection: "asc" | "desc" | null; onSort: (field: string) => void; } export default function ProductTable({ products, 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.barcode || "-"}
{product.name} {product.brand && {product.brand}}
代號: {product.code}
{product.category?.name || '-'} {product.baseUnit?.name || '-'} {product.largeUnit ? ( 1 {product.largeUnit?.name} = {Number(product.conversionRate)} {product.baseUnit?.name} ) : ( '-' )}
{product.specification || '-'}
{product.specification && (

{product.specification}

)}
{product.location || '-'} {product.is_active ? ( 啟用 ) : ( 停用 )}
確認刪除 確定要刪除「{product.name}」嗎?此操作無法復原。 取消 onDelete(product.id)} className="bg-red-600 hover:bg-red-700" > 刪除
)) )}
{/* 條碼查看對話框 - Temporarily disabled */} {/* {selectedProduct && ( )} */} ); }