From 356929b399ef31a4de82906267df438cf29ea59d Mon Sep 17 00:00:00 2001 From: 0-Zz-ang Date: Thu, 10 Jul 2025 15:56:13 +0900 Subject: 인터페이스 관련 파일 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/delete-integration-dialog.tsx | 154 +++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 lib/integration/table/delete-integration-dialog.tsx (limited to 'lib/integration/table/delete-integration-dialog.tsx') diff --git a/lib/integration/table/delete-integration-dialog.tsx b/lib/integration/table/delete-integration-dialog.tsx new file mode 100644 index 00000000..5ce9676d --- /dev/null +++ b/lib/integration/table/delete-integration-dialog.tsx @@ -0,0 +1,154 @@ +"use client" + +import * as React from "react" +import { type Row } from "@tanstack/react-table" +import { Loader, Trash } from "lucide-react" +import { toast } from "sonner" + +import { useMediaQuery } from "@/hooks/use-media-query" +import { Button } from "@/components/ui/button" +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { + Drawer, + DrawerClose, + DrawerContent, + DrawerDescription, + DrawerFooter, + DrawerHeader, + DrawerTitle, + DrawerTrigger, +} from "@/components/ui/drawer" + +import { deleteIntegration } from "../service" +import { integrations } from "@/db/schema/integration" + +interface DeleteIntegrationDialogProps + extends React.ComponentPropsWithoutRef { + integrations: Row["original"][] + showTrigger?: boolean + onSuccess?: () => void +} + +export function DeleteIntegrationDialog({ + integrations: integrationData = [], + showTrigger = true, + onSuccess, + ...props +}: DeleteIntegrationDialogProps) { + const [isDeletePending, startDeleteTransition] = React.useTransition() + const isDesktop = useMediaQuery("(min-width: 640px)") + + function onDelete() { + startDeleteTransition(async () => { + try { + // 각 통합을 순차적으로 삭제 + for (const integrationItem of integrationData) { + const result = await deleteIntegration(integrationItem.id) + if (!result.success) { + toast.error(`인터페이스 ${integrationItem.name} 삭제 실패: ${result.error}`) + return + } + } + + props.onOpenChange?.(false) + toast.success("인터페이스가 성공적으로 삭제되었습니다.") + onSuccess?.() + } catch (error) { + console.error("Delete error:", error) + toast.error("인터페이스 삭제 중 오류가 발생했습니다.") + } + }) + } + + if (isDesktop) { + return ( + + {showTrigger ? ( + + + + ) : null} + + + 정말로 삭제하시겠습니까? + + 이 작업은 되돌릴 수 없습니다. 선택된{" "} + {integrationData?.length ?? 0} + 개의 인터페이스를 서버에서 영구적으로 삭제합니다. + + + + + + + + + + + ) + } + + return ( + + {showTrigger ? ( + + + + ) : null} + + + 정말로 삭제하시겠습니까? + + 이 작업은 되돌릴 수 없습니다. 선택된{" "} + {integrationData?.length ?? 0} + 개의 인터페이스를 서버에서 영구적으로 삭제합니다. + + + + + + + + + + + ) +} \ No newline at end of file -- cgit v1.2.3