diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rfqs/table/attachment-rfq-sheet.tsx | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/rfqs/table/attachment-rfq-sheet.tsx b/lib/rfqs/table/attachment-rfq-sheet.tsx index 75235b32..fdfb5e9a 100644 --- a/lib/rfqs/table/attachment-rfq-sheet.tsx +++ b/lib/rfqs/table/attachment-rfq-sheet.tsx @@ -24,7 +24,7 @@ import { FormMessage, FormDescription } from "@/components/ui/form" -import { Trash2, Plus, Loader, Download, X, Eye, AlertCircle } from "lucide-react" +import { Loader, Download, X, Eye, AlertCircle } from "lucide-react" import { useToast } from "@/hooks/use-toast" import { Badge } from "@/components/ui/badge" @@ -45,15 +45,15 @@ import { FileListInfo, FileListItem, FileListName, - FileListSize, } from "@/components/ui/file-list" import prettyBytes from "pretty-bytes" import { processRfqAttachments } from "../service" -import { format } from "path" import { formatDate } from "@/lib/utils" import { RfqType } from "../validations" import { RfqWithItemCount } from "@/db/schema/rfq" +import { quickDownload } from "@/lib/file-download" +import { type FileRejection } from "react-dropzone" const MAX_FILE_SIZE = 6e8 // 600MB @@ -116,7 +116,7 @@ export function RfqAttachmentsSheet({ const { toast } = useToast() const [isPending, startUpdate] = React.useTransition() const rfqId = rfq?.rfqId ?? 0; - + // 편집 가능 여부 확인 - DRAFT 상태일 때만 편집 가능 const isEditable = rfq?.status === "DRAFT"; @@ -167,7 +167,7 @@ export function RfqAttachmentsSheet({ async function onSubmit(data: AttachmentsFormValues) { // 편집 불가능한 상태에서는 제출 방지 if (!isEditable) return; - + startUpdate(async () => { try { const removedExistingIds = findRemovedExistingIds(data) @@ -225,10 +225,10 @@ export function RfqAttachmentsSheet({ } /** 드롭존에서 파일 거부(에러) */ - function handleDropRejected(fileRejections: any[]) { + function handleDropRejected(fileRejections: FileRejection[]) { // 편집 불가능한 상태에서는 무시 if (!isEditable) return; - + fileRejections.forEach((rej) => { toast({ variant: "destructive", @@ -245,8 +245,8 @@ export function RfqAttachmentsSheet({ <SheetTitle className="flex items-center gap-2"> {isEditable ? "Manage Attachments" : "View Attachments"} {rfq?.status && ( - <Badge - variant={rfq.status === "DRAFT" ? "outline" : "secondary"} + <Badge + variant={rfq.status === "DRAFT" ? "outline" : "secondary"} className="ml-1" > {rfq.status} @@ -298,15 +298,14 @@ export function RfqAttachmentsSheet({ <div className="flex items-center gap-2"> {/* 1) Download button (if filePath) */} {field.filePath && ( - <a - href={`/api/rfq-download?path=${encodeURIComponent(field.filePath)}`} - download={field.fileName} - className="text-sm" + <Button + variant="ghost" + size="icon" + type="button" + onClick={() => quickDownload(field.filePath, field.fileName)} > - <Button variant="ghost" size="icon" type="button"> - <Download className="h-4 w-4" /> - </Button> - </a> + <Download className="h-4 w-4" /> + </Button> )} {/* 2) Remove button - 편집 가능할 때만 표시 */} {isEditable && ( @@ -413,8 +412,8 @@ export function RfqAttachmentsSheet({ </Button> </SheetClose> {isEditable && ( - <Button - type="submit" + <Button + type="submit" disabled={isPending || (form.getValues().newUploads.length === 0 && defaultAttachments.length === form.getValues().existing.length)} > {isPending && <Loader className="mr-2 h-4 w-4 animate-spin" />} |
