Files
star-erp/resources/js/Components/PurchaseOrder/PurchaseOrderActions.tsx
sky121113 e15f85642c
Some checks failed
Koori-ERP-Deploy / auto-deploy (push) Failing after 12s
chore: bypass dns using host ip
2025-12-30 17:05:19 +08:00

57 lines
2.0 KiB
TypeScript

import { Edit, Eye, Trash2 } from "lucide-react";
import { Button } from "@/Components/ui/button";
import { Link, useForm } from "@inertiajs/react";
import type { PurchaseOrder } from "@/types/purchase-order";
import { toast } from "sonner";
export function PurchaseOrderActions({
order,
}: { order: PurchaseOrder }) {
const { delete: destroy, processing } = useForm({});
const handleDelete = () => {
if (confirm(`確定要刪除採購單 ${order.poNumber} 嗎?`)) {
// @ts-ignore
destroy(route('purchase-orders.destroy', order.id), {
onSuccess: () => toast.success("採購單已成功刪除"),
onError: (errors: any) => toast.error(errors.error || "刪除過程中發生錯誤"),
});
}
};
return (
<div className="flex justify-end gap-2">
<Link href={`/purchase-orders/${order.id}`}>
<Button
variant="outline"
size="sm"
className="button-outlined-primary h-8 w-8 p-0"
title="查看採購單"
>
<Eye className="h-4 w-4" />
</Button>
</Link>
<Link href={`/purchase-orders/${order.id}/edit`}>
<Button
variant="outline"
size="sm"
className="button-outlined-primary h-8 w-8 p-0"
title="編輯採購單"
>
<Edit className="h-4 w-4" />
</Button>
</Link>
<Button
variant="outline"
size="sm"
className="hover:bg-red-50 hover:text-red-600 hover:border-red-200 text-gray-500 h-8 w-8 p-0 transition-colors"
title="刪除採購單"
onClick={handleDelete}
disabled={processing}
>
<Trash2 className="h-4 w-4" />
</Button>
</div>
);
}