diff options
Diffstat (limited to 'lib/techsales-rfq/table/tech-sales-quotation-attachments-sheet.tsx')
| -rw-r--r-- | lib/techsales-rfq/table/tech-sales-quotation-attachments-sheet.tsx | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/techsales-rfq/table/tech-sales-quotation-attachments-sheet.tsx b/lib/techsales-rfq/table/tech-sales-quotation-attachments-sheet.tsx index 08363535..a03839c1 100644 --- a/lib/techsales-rfq/table/tech-sales-quotation-attachments-sheet.tsx +++ b/lib/techsales-rfq/table/tech-sales-quotation-attachments-sheet.tsx @@ -14,7 +14,6 @@ import { Badge } from "@/components/ui/badge" import { Separator } from "@/components/ui/separator"
import { formatDate } from "@/lib/utils"
import prettyBytes from "pretty-bytes"
-import { downloadFile } from "@/lib/file-download"
// 견적서 첨부파일 타입 정의
export interface QuotationAttachment {
@@ -80,20 +79,26 @@ export function TechSalesQuotationAttachmentsSheet({ // 기본 파일
return <File className="h-5 w-5 text-gray-500" />;
};
-
- // 파일 다운로드 처리
- const handleDownload = (attachment: QuotationAttachment) => {
- downloadFile(attachment.filePath, attachment.originalFileName || attachment.fileName)
- /*
- const link = document.createElement('a');
- link.href = attachment.filePath;
- link.download = attachment.originalFileName || attachment.fileName;
- link.target = '_blank';
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- */
- };
+
+ // 파일 다운로드 핸들러
+ const handleDownloadClick = React.useCallback(async (attachment: QuotationAttachment) => {
+ try {
+ const { downloadFile } = await import('@/lib/file-download');
+ await downloadFile(attachment.filePath, attachment.originalFileName || attachment.fileName, {
+ showToast: true,
+ onError: (error) => {
+ console.error('다운로드 오류:', error);
+ // TODO: toast 에러 메시지 추가 (sonner import 필요)
+ },
+ onSuccess: (fileName, fileSize) => {
+ console.log(`다운로드 성공: ${fileName} (${fileSize} bytes)`);
+ }
+ });
+ } catch (error) {
+ console.error('다운로드 오류:', error);
+ // TODO: toast 에러 메시지 추가 (sonner import 필요)
+ }
+ }, []);
// 리비전별로 첨부파일 그룹핑
const groupedAttachments = React.useMemo(() => {
@@ -176,7 +181,7 @@ export function TechSalesQuotationAttachmentsSheet({ className="flex items-start gap-3 p-3 border rounded-lg hover:bg-muted/50 transition-colors ml-4"
>
<div className="mt-1">
- {getFileIcon(attachment.fileName)}
+ {getFileIcon(attachment.originalFileName || attachment.fileName)}
</div>
<div className="flex-1 min-w-0">
@@ -211,7 +216,7 @@ export function TechSalesQuotationAttachmentsSheet({ variant="ghost"
size="icon"
className="h-8 w-8"
- onClick={() => handleDownload(attachment)}
+ onClick={() => handleDownloadClick(attachment)}
title="다운로드"
>
<Download className="h-4 w-4" />
|
