import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/Components/ui/table"; import { Button } from "@/Components/ui/button"; import { Pencil, Trash2, Eye, 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 { Vendor } from "@/Pages/Vendor/Index"; interface VendorTableProps { vendors: Vendor[]; onView: (vendor: Vendor) => void; onEdit: (vendor: Vendor) => void; onDelete: (id: number) => void; sortField: string | null; sortDirection: "asc" | "desc" | null; onSort: (field: string) => void; } export default function VendorTable({ vendors, onView, onEdit, onDelete, sortField, sortDirection, onSort, }: VendorTableProps) { const SortIcon = ({ field }: { field: string }) => { if (sortField !== field) { return ; } if (sortDirection === "asc") { return ; } if (sortDirection === "desc") { return ; } return ; }; return (
# 操作 {vendors.length === 0 ? ( 無符合條件的廠商資料 ) : ( vendors.map((vendor, index) => ( {index + 1} {vendor.code}
{vendor.name} {vendor.short_name && {vendor.short_name}}
{vendor.owner || '-'} {vendor.contact_name || '-'} {vendor.phone || vendor.tel || '-'}
確認刪除 確定要刪除廠商「{vendor.name}」嗎?此操作無法復原。 取消 onDelete(vendor.id)} className="bg-red-600 hover:bg-red-700" > 刪除
)) )}
); }