diff options
| author | kiman Kim <94714426+rlaks5757@users.noreply.github.com> | 2025-04-02 13:49:27 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-02 13:49:27 +0900 |
| commit | 9b6269c856516f3987ee249c6131a44728e276e2 (patch) | |
| tree | 9a408a0f570ed81c88d521f43f8d8243a79489bc /components/form-data/temp-download-btn.tsx | |
| parent | 562b41a20c2af8fe1330c5db6702dd291ab6a85d (diff) | |
| parent | df6a532921c6c39f68923237d261a1abd6a105ef (diff) | |
Merge pull request #10 from DTS-Development/features
Vendor-data Page 작업물 Merge
Diffstat (limited to 'components/form-data/temp-download-btn.tsx')
| -rw-r--r-- | components/form-data/temp-download-btn.tsx | 45 |
1 files changed, 45 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..a5f963e4 --- /dev/null +++ b/components/form-data/temp-download-btn.tsx @@ -0,0 +1,45 @@ +"use client"; + +import React from "react"; +import Image from "next/image"; +import { useToast } from "@/hooks/use-toast"; +import { toast as toastMessage } from "sonner"; +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} + > + <Image + src="/icons/temp_sample_icon.svg" + alt="Template Sample Download Icon" + width={20} + height={20} + /> + </Button> + ); +}; |
