summaryrefslogtreecommitdiff
path: root/components/form-data/var-list-download-btn.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/form-data/var-list-download-btn.tsx')
-rw-r--r--components/form-data/var-list-download-btn.tsx28
1 files changed, 19 insertions, 9 deletions
diff --git a/components/form-data/var-list-download-btn.tsx b/components/form-data/var-list-download-btn.tsx
index bbadf893..9d09ab8c 100644
--- a/components/form-data/var-list-download-btn.tsx
+++ b/components/form-data/var-list-download-btn.tsx
@@ -8,6 +8,8 @@ import ExcelJS from "exceljs";
import { saveAs } from "file-saver";
import { Button } from "@/components/ui/button";
import { DataTableColumnJSON } from "./form-data-table-columns";
+import { useParams } from "next/navigation";
+import { useTranslation } from "@/i18n/client";
interface VarListDownloadBtnProps {
columnsJSON: DataTableColumnJSON[];
@@ -19,6 +21,10 @@ export const VarListDownloadBtn: FC<VarListDownloadBtnProps> = ({
formCode,
}) => {
const { toast } = useToast();
+
+ const params = useParams();
+ const lng = (params?.lng as string) || "ko";
+ const { t } = useTranslation(lng, "engineering");
const downloadReportVarList = async () => {
try {
@@ -33,7 +39,10 @@ export const VarListDownloadBtn: FC<VarListDownloadBtnProps> = ({
validationSheet.state = "hidden"; // 시트 숨김 처리
// 1. 데이터 시트에 헤더 추가
- const headers = ["Table Column Label", "Report Variable"];
+ const headers = [
+ t("varListDownload.headers.tableColumnLabel"),
+ t("varListDownload.headers.reportVariable")
+ ];
worksheet.addRow(headers);
// 헤더 스타일 적용
@@ -50,7 +59,7 @@ export const VarListDownloadBtn: FC<VarListDownloadBtnProps> = ({
// 2. 데이터 행 추가
columnsJSON.forEach((row) => {
- console.log(row)
+ console.log(row);
const { displayLabel, key } = row;
// const labelConvert = label.replaceAll(" ", "_");
@@ -81,13 +90,14 @@ export const VarListDownloadBtn: FC<VarListDownloadBtnProps> = ({
});
const buffer = await workbook.xlsx.writeBuffer();
- saveAs(new Blob([buffer]), `${formCode}_report_varible_list.xlsx`);
- toastMessage.success("Report Varible List File 다운로드 완료!");
+ const fileName = `${formCode}${t("varListDownload.fileNameSuffix")}`;
+ saveAs(new Blob([buffer]), fileName);
+ toastMessage.success(t("varListDownload.messages.downloadComplete"));
} catch (err) {
console.log(err);
toast({
- title: "Error",
- description: "Variable List 파일을 찾을 수가 없습니다.",
+ title: t("varListDownload.messages.errorTitle"),
+ description: t("varListDownload.messages.errorDescription"),
variant: "destructive",
});
}
@@ -97,16 +107,16 @@ export const VarListDownloadBtn: FC<VarListDownloadBtnProps> = ({
<Button
variant="outline"
className="relative px-[8px] py-[6px] flex-1"
- aria-label="Variable List Download"
+ aria-label={t("varListDownload.buttonAriaLabel")}
onClick={downloadReportVarList}
>
<Image
src="/icons/var_list_icon.svg"
- alt="Template Sample Download Icon"
+ alt={t("varListDownload.iconAltText")}
width={16}
height={16}
/>
- <div className='text-[12px]'>Variable List Download</div>
+ <div className="text-[12px]">{t("varListDownload.buttonText")}</div>
</Button>
);
}; \ No newline at end of file