From c4c3f12b4a6d1a3c09b797e1a160747cac8761e9 Mon Sep 17 00:00:00 2001
From: rlaks5757 <rlaks5757@gmail.com>
Date: Fri, 28 Mar 2025 11:27:25 +0900
Subject: template file download 개발 완료
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/form-data/form-data-report-batch-dialog.tsx | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

(limited to 'components/form-data/form-data-report-batch-dialog.tsx')

diff --git a/components/form-data/form-data-report-batch-dialog.tsx b/components/form-data/form-data-report-batch-dialog.tsx
index 614f890e..6c690363 100644
--- a/components/form-data/form-data-report-batch-dialog.tsx
+++ b/components/form-data/form-data-report-batch-dialog.tsx
@@ -8,8 +8,10 @@ import React, {
   useEffect,
 } from "react";
 import { useToast } from "@/hooks/use-toast";
+import { toast as toastMessage} from "sonner";
 import prettyBytes from "pretty-bytes";
 import { X, Loader2 } from "lucide-react";
+import { saveAs } from 'file-saver';
 import { Badge } from "@/components/ui/badge";
 import {
   Dialog,
@@ -159,15 +161,14 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({
 
       if (reqeustCreateReport.ok) {
         const blob = await reqeustCreateReport.blob();
-        const url = window.URL.createObjectURL(blob);
-        const a = document.createElement("a");
-        a.href = url;
-        a.download = `${formCode}.pdf`;
-        a.click();
-        window.URL.revokeObjectURL(url);
+
+        saveAs(blob, `${formCode}.pdf`);        
+
+        toastMessage.success("Report 다운로드 완료!")
       } else {
         const err = await reqeustCreateReport.json();
         console.error("에러:", err);
+        throw new Error(err.message)
       }
     } catch (err) {
       console.error(err);
-- 
cgit v1.2.3

