summaryrefslogtreecommitdiff
path: root/components/form-data/temp-download-btn.tsx
diff options
context:
space:
mode:
authorrlaks5757 <rlaks5757@gmail.com>2025-04-01 11:58:20 +0900
committerrlaks5757 <rlaks5757@gmail.com>2025-04-01 11:58:20 +0900
commitcc2c3def63f47063d4fa8b01f9f61eafdd52805c (patch)
treef67b6e61d8f353a7f5fb06828ed93a65414c8f92 /components/form-data/temp-download-btn.tsx
parent3e47b8275454452324e3b6a7607f2db361110b0e (diff)
template-upload-dialog component 세분화
Diffstat (limited to 'components/form-data/temp-download-btn.tsx')
-rw-r--r--components/form-data/temp-download-btn.tsx40
1 files changed, 40 insertions, 0 deletions
diff --git a/components/form-data/temp-download-btn.tsx b/components/form-data/temp-download-btn.tsx
new file mode 100644
index 00000000..01fff569
--- /dev/null
+++ b/components/form-data/temp-download-btn.tsx
@@ -0,0 +1,40 @@
+"use client";
+
+import React from "react";
+import { useToast } from "@/hooks/use-toast";
+import { toast as toastMessage } from "sonner";
+import { Download } from "lucide-react";
+import { saveAs } from "file-saver";
+import { Button } from "@/components/ui/button";
+import { getReportTempFileData } from "@/lib/forms/services";
+
+export const TempDownloadBtn = () => {
+ const { toast } = useToast();
+
+ const downloadTempFile = async () => {
+ try {
+ const { fileName, fileType, base64 } = await getReportTempFileData();
+
+ saveAs(`data:${fileType};base64,${base64}`, fileName);
+
+ toastMessage.success("Report Sample File 다운로드 완료!");
+ } catch (err) {
+ console.log(err);
+ toast({
+ title: "Error",
+ description: "Sample File을 찾을 수가 없습니다.",
+ variant: "destructive",
+ });
+ }
+ };
+ return (
+ <Button
+ variant="ghost"
+ className="relative p-2"
+ aria-label="Template Sample Download"
+ onClick={downloadTempFile}
+ >
+ <Download />
+ </Button>
+ );
+};