summaryrefslogtreecommitdiff
path: root/lib/b-rfq/attachment/delete-attachment-dialog.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/b-rfq/attachment/delete-attachment-dialog.tsx')
-rw-r--r--lib/b-rfq/attachment/delete-attachment-dialog.tsx182
1 files changed, 0 insertions, 182 deletions
diff --git a/lib/b-rfq/attachment/delete-attachment-dialog.tsx b/lib/b-rfq/attachment/delete-attachment-dialog.tsx
deleted file mode 100644
index b5471520..00000000
--- a/lib/b-rfq/attachment/delete-attachment-dialog.tsx
+++ /dev/null
@@ -1,182 +0,0 @@
-"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<typeof Dialog> {
- attachments: Row<RfqAttachment>["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 (
- <Dialog {...props}>
- {showTrigger ? (
- <DialogTrigger asChild>
- <Button variant="outline" size="sm">
- <Trash className="mr-2 size-4" aria-hidden="true" />
- 삭제 ({attachments.length})
- </Button>
- </DialogTrigger>
- ) : null}
- <DialogContent>
- <DialogHeader>
- <DialogTitle>정말로 삭제하시겠습니까?</DialogTitle>
- <DialogDescription className="space-y-2">
- <div>이 작업은 되돌릴 수 없습니다.</div>
- <div>{deleteWarning}</div>
- {attachments.length <= 3 && (
- <div className="mt-3 p-2 bg-gray-50 rounded-md">
- <div className="font-medium text-sm">삭제될 파일:</div>
- <ul className="text-sm text-gray-600 mt-1">
- {attachments.map((attachment) => (
- <li key={attachment.id} className="truncate">
- • {attachment.serialNo}: {attachment.originalFileName} ({attachment.currentRevision})
- </li>
- ))}
- </ul>
- </div>
- )}
- </DialogDescription>
- </DialogHeader>
- <DialogFooter className="gap-2 sm:space-x-0">
- <DialogClose asChild>
- <Button variant="outline">취소</Button>
- </DialogClose>
- <Button
- aria-label="Delete selected attachments"
- variant="destructive"
- onClick={onDelete}
- disabled={isDeletePending}
- >
- {isDeletePending && (
- <Loader
- className="mr-2 size-4 animate-spin"
- aria-hidden="true"
- />
- )}
- 삭제
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- )
- }
-
- return (
- <Drawer {...props}>
- {showTrigger ? (
- <DrawerTrigger asChild>
- <Button variant="outline" size="sm">
- <Trash className="mr-2 size-4" aria-hidden="true" />
- 삭제 ({attachments.length})
- </Button>
- </DrawerTrigger>
- ) : null}
- <DrawerContent>
- <DrawerHeader>
- <DrawerTitle>정말로 삭제하시겠습니까?</DrawerTitle>
- <DrawerDescription className="space-y-2">
- <div>이 작업은 되돌릴 수 없습니다.</div>
- <div>{deleteWarning}</div>
- {attachments.length <= 3 && (
- <div className="mt-3 p-2 bg-gray-50 rounded-md">
- <div className="font-medium text-sm">삭제될 파일:</div>
- <ul className="text-sm text-gray-600 mt-1">
- {attachments.map((attachment) => (
- <li key={attachment.id} className="truncate">
- • {attachment.serialNo}: {attachment.originalFileName} ({attachment.currentRevision})
- </li>
- ))}
- </ul>
- </div>
- )}
- </DrawerDescription>
- </DrawerHeader>
- <DrawerFooter className="gap-2 sm:space-x-0">
- <DrawerClose asChild>
- <Button variant="outline">취소</Button>
- </DrawerClose>
- <Button
- aria-label="Delete selected attachments"
- variant="destructive"
- onClick={onDelete}
- disabled={isDeletePending}
- >
- {isDeletePending && (
- <Loader className="mr-2 size-4 animate-spin" aria-hidden="true" />
- )}
- 삭제
- </Button>
- </DrawerFooter>
- </DrawerContent>
- </Drawer>
- )
-} \ No newline at end of file