"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 { deleteRfqAttachments } from "../service" // 첨부파일 타입 (실제 타입에 맞게 조정 필요) type RfqAttachment = { id: number serialNo: string originalFileName: string attachmentType: string currentRevision: string } interface DeleteAttachmentsDialogProps extends React.ComponentPropsWithoutRef { attachments: Row["original"][] showTrigger?: boolean onSuccess?: () => void } export function DeleteAttachmentsDialog({ attachments, showTrigger = true, onSuccess, ...props }: DeleteAttachmentsDialogProps) { const [isDeletePending, startDeleteTransition] = React.useTransition() const isDesktop = useMediaQuery("(min-width: 640px)") function onDelete() { startDeleteTransition(async () => { const result = await deleteRfqAttachments({ ids: attachments.map((attachment) => attachment.id), }) if (!result.success) { toast.error(result.message) return } props.onOpenChange?.(false) toast.success(result.message) onSuccess?.() }) } const attachmentText = attachments.length === 1 ? "첨부파일" : "첨부파일들" const deleteWarning = `선택된 ${attachments.length}개의 ${attachmentText}과 모든 리비전이 영구적으로 삭제됩니다.` if (isDesktop) { return ( {showTrigger ? ( ) : null} 정말로 삭제하시겠습니까?
이 작업은 되돌릴 수 없습니다.
{deleteWarning}
{attachments.length <= 3 && (
삭제될 파일:
    {attachments.map((attachment) => (
  • • {attachment.serialNo}: {attachment.originalFileName} ({attachment.currentRevision})
  • ))}
)}
) } return ( {showTrigger ? ( ) : null} 정말로 삭제하시겠습니까?
이 작업은 되돌릴 수 없습니다.
{deleteWarning}
{attachments.length <= 3 && (
삭제될 파일:
    {attachments.map((attachment) => (
  • • {attachment.serialNo}: {attachment.originalFileName} ({attachment.currentRevision})
  • ))}
)}
) }