From 675b4e3d8ffcb57a041db285417d81e61284d900 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Sun, 14 Sep 2025 05:28:01 +0000 Subject: (대표님) RFQ-last, tbe-last, 기본계약 템플릿 내 견적,입찰,계약 추가, env.dev NAS_PATH 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/rfq-last/vendor/delete-vendor-dialog.tsx | 124 +++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 lib/rfq-last/vendor/delete-vendor-dialog.tsx (limited to 'lib/rfq-last/vendor/delete-vendor-dialog.tsx') diff --git a/lib/rfq-last/vendor/delete-vendor-dialog.tsx b/lib/rfq-last/vendor/delete-vendor-dialog.tsx new file mode 100644 index 00000000..7634509e --- /dev/null +++ b/lib/rfq-last/vendor/delete-vendor-dialog.tsx @@ -0,0 +1,124 @@ +// components/delete-vendor-dialog.tsx +"use client"; + +import * as React from "react"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; +import { AlertTriangle, Loader2 } from "lucide-react"; +import { toast } from "sonner"; +import { deleteRfqVendor } from "../service"; + +interface DeleteVendorDialogProps { + open: boolean; + onOpenChange: (open: boolean) => void; + rfqId: number; + vendorData: { + detailId: number; + vendorId: number; + vendorName: string; + vendorCode?: string | null; + hasQuotation: boolean; // quotationStatus가 있는지 여부 + }; + onSuccess?: () => void; +} + +export function DeleteVendorDialog({ + open, + onOpenChange, + rfqId, + vendorData, + onSuccess, +}: DeleteVendorDialogProps) { + const [isDeleting, setIsDeleting] = React.useState(false); + + const handleDelete = async () => { + // quotationStatus가 있으면 삭제 불가 (추가 보호) + if (vendorData.hasQuotation) { + toast.error("견적서가 제출된 벤더는 삭제할 수 없습니다."); + return; + } + + try { + setIsDeleting(true); + + const result = await deleteRfqVendor({ + rfqId, + detailId: vendorData.detailId, + vendorId: vendorData.vendorId, + }); + + if (result.success) { + toast.success(result.message || "벤더가 삭제되었습니다."); + onSuccess?.(); + onOpenChange(false); + } else { + toast.error(result.message || "삭제에 실패했습니다."); + } + } catch (error) { + console.error("벤더 삭제 실패:", error); + toast.error("삭제 중 오류가 발생했습니다."); + } finally { + setIsDeleting(false); + } + }; + + return ( + + + + + + 벤더 삭제 확인 + + +
+

+ {vendorData.vendorName} + {vendorData.vendorCode && ` (${vendorData.vendorCode})`}을(를) + RFQ 목록에서 삭제하시겠습니까? +

+ + {vendorData.hasQuotation && ( +
+

⚠️ 주의: 견적서가 제출된 벤더입니다.

+

견적서가 제출된 벤더는 삭제할 수 없습니다.

+
+ )} + + {!vendorData.hasQuotation && ( +

+ 이 작업은 되돌릴 수 없습니다. 삭제 후에는 해당 벤더의 모든 RFQ 관련 정보가 제거됩니다. +

+ )} +
+
+
+ + 취소 + + {isDeleting ? ( + <> + + 삭제 중... + + ) : ( + "삭제" + )} + + +
+
+ ); +} \ No newline at end of file -- cgit v1.2.3