diff options
| author | kiman Kim <94714426+rlaks5757@users.noreply.github.com> | 2025-04-02 13:45:49 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-02 13:45:49 +0900 |
| commit | df6a532921c6c39f68923237d261a1abd6a105ef (patch) | |
| tree | 71d5aeb2ddcbc4c82e17ea38f082e410711c2655 /components/form-data/temp-download-btn.tsx | |
| parent | 4b2d468701ab069fdc2347f345da56abe37c70be (diff) | |
| parent | d8a70fa8802ad066fee68aca54df7fa41461a841 (diff) | |
Merge pull request #7 from DTS-Development/feature/kiman
vendor-document-viewer select row 수정
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> + ); +}; |
