diff options
Diffstat (limited to 'components/form-data/form-data-report-batch-dialog.tsx')
| -rw-r--r-- | components/form-data/form-data-report-batch-dialog.tsx | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/components/form-data/form-data-report-batch-dialog.tsx b/components/form-data/form-data-report-batch-dialog.tsx index 53f8c489..fdd36c80 100644 --- a/components/form-data/form-data-report-batch-dialog.tsx +++ b/components/form-data/form-data-report-batch-dialog.tsx @@ -7,6 +7,8 @@ import React, { useState, useEffect, } from "react"; +import { useParams } from "next/navigation"; +import { useTranslation } from "@/i18n/client"; import { useToast } from "@/hooks/use-toast"; import { toast as toastMessage } from "sonner"; import prettyBytes from "pretty-bytes"; @@ -84,6 +86,10 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ formCode, }) => { const { toast } = useToast(); + const params = useParams(); + const lng = (params?.lng as string) || "ko"; + const { t } = useTranslation(lng, "engineering"); + const [tempList, setTempList] = useState<tempFile[]>([]); const [selectTemp, setSelectTemp] = useState<string>(""); const [selectedFiles, setSelectedFiles] = useState<File[]>([]); @@ -115,9 +121,9 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ fileRejections.forEach((rejection) => { toast({ variant: "destructive", - title: "File Error", + title: t("batchReport.fileError"), description: `${rejection.file.name}: ${ - rejection.errors[0]?.message || "Upload failed" + rejection.errors[0]?.message || t("batchReport.uploadFailed") }`, }); }); @@ -164,7 +170,7 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ if (requestCreateReport.ok) { const blob = await requestCreateReport.blob(); saveAs(blob, `${formCode}.pdf`); - toastMessage.success("Report 다운로드 완료!"); + toastMessage.success(t("batchReport.downloadComplete")); } else { const err = await requestCreateReport.json(); console.error("에러:", err); @@ -173,8 +179,8 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ } catch (err) { console.error(err); toast({ - title: "Error", - description: "Report 생성 중 오류가 발생했습니다.", + title: t("batchReport.error"), + description: t("batchReport.reportGenerationError"), variant: "destructive", }); } finally { @@ -219,7 +225,7 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ const blob = await requestCreateReport.blob(); setGeneratedFileBlob(blob); setPublishDialogOpen(true); - toastMessage.success("문서가 생성되었습니다. 발행 정보를 입력해주세요."); + toastMessage.success(t("batchReport.documentGenerated")); } else { const err = await requestCreateReport.json(); console.error("에러:", err); @@ -228,8 +234,8 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ } catch (err) { console.error(err); toast({ - title: "Error", - description: "문서 생성 중 오류가 발생했습니다.", + title: t("batchReport.error"), + description: t("batchReport.documentGenerationError"), variant: "destructive", }); } finally { @@ -242,17 +248,16 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ <Dialog open={open} onOpenChange={onClose}> <DialogContent className="w-[600px]" style={{ maxWidth: "none" }}> <DialogHeader> - <DialogTitle>Vendor Document Create</DialogTitle> + <DialogTitle>{t("batchReport.dialogTitle")}</DialogTitle> <DialogDescription> - Vendor Document Template을 선택하신 후 갑지를 업로드하여 주시기 - 바랍니다. + {t("batchReport.dialogDescription")} </DialogDescription> </DialogHeader> <div className="h-[60px]"> - <Label>Vendor Document Template Select</Label> + <Label>{t("batchReport.templateSelectLabel")}</Label> <Select value={selectTemp} onValueChange={setSelectTemp}> <SelectTrigger className="w-[100%]"> - <SelectValue placeholder="사용하시고자하는 Report Template를 선택하여 주시기 바랍니다." /> + <SelectValue placeholder={t("batchReport.templateSelectPlaceholder")} /> </SelectTrigger> <SelectContent> {tempList.map((c) => { @@ -268,7 +273,7 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ </Select> </div> <div> - <Label>Vendor Document Cover Page Upload(.docx)</Label> + <Label>{t("batchReport.coverPageUploadLabel")}</Label> <Dropzone maxSize={MAX_FILE_SIZE} multiple={false} @@ -284,16 +289,17 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ <div className="flex items-center gap-6"> <DropzoneUploadIcon /> <div className="grid gap-0.5"> - <DropzoneTitle>파일을 여기에 드롭하세요</DropzoneTitle> + <DropzoneTitle>{t("batchReport.dropFileHere")}</DropzoneTitle> <DropzoneDescription> - 또는 클릭하여 파일을 선택하세요. 최대 크기:{" "} - {maxSize ? prettyBytes(maxSize) : "무제한"} + {t("batchReport.orClickToSelect", { + maxSize: maxSize ? prettyBytes(maxSize) : t("batchReport.unlimited") + })} </DropzoneDescription> </div> </div> </DropzoneZone> <Label className="text-xs text-muted-foreground"> - 여러 파일을 선택할 수 있습니다. + {t("batchReport.multipleFilesAllowed")} </Label> </> )} @@ -304,15 +310,18 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ <div className="grid gap-2"> <div className="flex items-center justify-between"> <h6 className="text-sm font-semibold"> - 선택된 파일 ({selectedFiles.length}) + {t("batchReport.selectedFiles", { count: selectedFiles.length })} </h6> - <Badge variant="secondary">{selectedFiles.length}개 파일</Badge> + <Badge variant="secondary"> + {t("batchReport.fileCount", { count: selectedFiles.length })} + </Badge> </div> <ScrollArea> <UploadFileItem selectedFiles={selectedFiles} removeFile={removeFile} isUploading={isUploading} + t={t} /> </ScrollArea> </div> @@ -331,7 +340,7 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ className="mr-2" > {isUploading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} - Publish + {t("batchReport.publish")} </Button> <Button disabled={ @@ -342,7 +351,7 @@ export const FormDataReportBatchDialog: FC<FormDataReportBatchDialogProps> = ({ onClick={submitData} > {isUploading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} - Create Vendor Document + {t("batchReport.createDocument")} </Button> </DialogFooter> </DialogContent> @@ -364,12 +373,14 @@ interface UploadFileItemProps { selectedFiles: File[]; removeFile: (index: number) => void; isUploading: boolean; + t: (key: string, options?: any) => string; } const UploadFileItem: FC<UploadFileItemProps> = ({ selectedFiles, removeFile, isUploading, + t, }) => { return ( <FileList className="max-h-[200px] gap-3"> @@ -388,7 +399,7 @@ const UploadFileItem: FC<UploadFileItemProps> = ({ disabled={isUploading} > <X className="h-4 w-4" /> - <span className="sr-only">Remove</span> + <span className="sr-only">{t("batchReport.remove")}</span> </FileListAction> </FileListHeader> </FileListItem> |
