From 89de030f3fc74f4d665517ad62141328d1702e5a Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Mon, 21 Jul 2025 02:55:28 +0000 Subject: (deprecated) 기존 rfq 첨부파일 다운로드 오류 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/rfqs/table/attachment-rfq-sheet.tsx | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'lib') 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({ {isEditable ? "Manage Attachments" : "View Attachments"} {rfq?.status && ( - {rfq.status} @@ -298,15 +298,14 @@ export function RfqAttachmentsSheet({
{/* 1) Download button (if filePath) */} {field.filePath && ( - quickDownload(field.filePath, field.fileName)} > - - + + )} {/* 2) Remove button - 편집 가능할 때만 표시 */} {isEditable && ( @@ -413,8 +412,8 @@ export function RfqAttachmentsSheet({ {isEditable && ( -