From 14f61e24947fb92dd71ec0a7196a6e815f8e66da Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 21 Jul 2025 07:54:26 +0000 Subject: (최겸)기술영업 RFQ 담당자 초대, 요구사항 반영 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/delete-contact-possible-items-dialog.tsx | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 lib/contact-possible-items/table/delete-contact-possible-items-dialog.tsx (limited to 'lib/contact-possible-items/table/delete-contact-possible-items-dialog.tsx') diff --git a/lib/contact-possible-items/table/delete-contact-possible-items-dialog.tsx b/lib/contact-possible-items/table/delete-contact-possible-items-dialog.tsx new file mode 100644 index 00000000..7c2fc459 --- /dev/null +++ b/lib/contact-possible-items/table/delete-contact-possible-items-dialog.tsx @@ -0,0 +1,111 @@ +"use client" + +import * as React from "react" +import { Loader2, Trash2Icon } from "lucide-react" + +import { + AlertDialog, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog" +import { Button } from "@/components/ui/button" +import { toast } from "@/hooks/use-toast" + +import { deleteContactPossibleItems, type ContactPossibleItemDetail } from "../service" + +interface DeleteContactPossibleItemsDialogProps { + contactPossibleItems: ContactPossibleItemDetail[] + showTrigger?: boolean + trigger?: React.ReactNode + open?: boolean + onOpenChange?: (open: boolean) => void + onSuccess?: () => void +} + +export function DeleteContactPossibleItemsDialog({ + contactPossibleItems, + showTrigger = true, + trigger, + open, + onOpenChange, + onSuccess, +}: DeleteContactPossibleItemsDialogProps) { + const [isDeletePending, startDeleteTransition] = React.useTransition() + + function onDelete() { + startDeleteTransition(async () => { + try { + const ids = contactPossibleItems.map((item) => item.id) + const result = await deleteContactPossibleItems(ids) + + if (result.success) { + toast({ + title: "성공", + description: `${contactPossibleItems.length}개의 담당자별 아이템이 삭제되었습니다.`, + }) + onSuccess?.() + onOpenChange?.(false) + } else { + toast({ + title: "오류", + description: result.error || "담당자별 아이템 삭제에 실패했습니다.", + variant: "destructive", + }) + } + } catch { + toast({ + title: "오류", + description: "담당자별 아이템 삭제 중 오류가 발생했습니다.", + variant: "destructive", + }) + } + }) + } + + const isMultiple = contactPossibleItems.length > 1 + + return ( + + {showTrigger && ( + + {trigger ?? ( + + )} + + )} + + + + {isMultiple + ? `${contactPossibleItems.length}개의 담당자별 아이템을 삭제하시겠습니까?` + : "담당자별 아이템을 삭제하시겠습니까?"} + + + 이 작업은 되돌릴 수 없습니다. 선택한 담당자별 아이템{isMultiple ? "들이" : "이"} 영구적으로 삭제됩니다. + + + + 취소 + + + + + ) +} \ No newline at end of file -- cgit v1.2.3