diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-04-02 09:56:20 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-04-02 09:56:20 +0000 |
| commit | 230ce796836c25df26c130dbcd616ef97d12b2ec (patch) | |
| tree | 033d982409c89b5f90db0b3772827139c7a8bf80 /components/form-data/temp-download-btn.tsx | |
| parent | dfdfae3018f8499240f48d28ce634f4a5c56e006 (diff) | |
| parent | 9b6269c856516f3987ee249c6131a44728e276e2 (diff) | |
Merge branch 'dev' of https://github.com/DTS-Development/SHI_EVCP into dev
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> + ); +}; |
