diff options
Diffstat (limited to 'components/form-data/form-data-report-temp-upload-tab.tsx')
| -rw-r--r-- | components/form-data/form-data-report-temp-upload-tab.tsx | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/components/form-data/form-data-report-temp-upload-tab.tsx b/components/form-data/form-data-report-temp-upload-tab.tsx index 32161e49..39d895a1 100644 --- a/components/form-data/form-data-report-temp-upload-tab.tsx +++ b/components/form-data/form-data-report-temp-upload-tab.tsx @@ -1,6 +1,8 @@ "use client"; import React, { FC, useState } 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"; @@ -43,6 +45,10 @@ export const FormDataReportTempUploadTab: FC< FormDataReportTempUploadTabProps > = ({ packageId, formId, uploaderType }) => { const { toast } = useToast(); + const params = useParams(); + const lng = (params?.lng as string) || "ko"; + const { t } = useTranslation(lng, "engineering"); + const [selectedFiles, setSelectedFiles] = useState<File[]>([]); const [isUploading, setIsUploading] = useState(false); const [uploadProgress, setUploadProgress] = useState(0); @@ -58,9 +64,9 @@ export const FormDataReportTempUploadTab: FC< fileRejections.forEach((rejection) => { toast({ variant: "destructive", - title: "File Error", + title: t("templateUploadTab.fileError"), description: `${rejection.file.name}: ${ - rejection.errors[0]?.message || "Upload failed" + rejection.errors[0]?.message || t("templateUploadTab.uploadFailed") }`, }); }); @@ -93,12 +99,12 @@ export const FormDataReportTempUploadTab: FC< successCount++; setUploadProgress(Math.round((successCount / totalFiles) * 100)); } - toastMessage.success("Template File 업로드 완료!"); + toastMessage.success(t("templateUploadTab.uploadComplete")); } catch (err) { console.error(err); toast({ - title: "Error", - description: "파일 업로드 중 오류가 발생했습니다.", + title: t("templateUploadTab.error"), + description: t("templateUploadTab.uploadError"), variant: "destructive", }); } finally { @@ -111,7 +117,7 @@ export const FormDataReportTempUploadTab: FC< return ( <div className='flex flex-col gap-4'> <div> - <Label>Vendor Document Template File Upload(.docx)</Label> + <Label>{t("templateUploadTab.uploadLabel")}</Label> <Dropzone maxSize={MAX_FILE_SIZE} multiple={true} @@ -127,16 +133,17 @@ export const FormDataReportTempUploadTab: FC< <div className="flex items-center gap-6"> <DropzoneUploadIcon /> <div className="grid gap-0.5"> - <DropzoneTitle>파일을 여기에 드롭하세요</DropzoneTitle> + <DropzoneTitle>{t("templateUploadTab.dropFileHere")}</DropzoneTitle> <DropzoneDescription> - 또는 클릭하여 파일을 선택하세요. 최대 크기:{" "} - {maxSize ? prettyBytes(maxSize) : "무제한"} + {t("templateUploadTab.orClickToSelect", { + maxSize: maxSize ? prettyBytes(maxSize) : t("templateUploadTab.unlimited") + })} </DropzoneDescription> </div> </div> </DropzoneZone> <Label className="text-xs text-muted-foreground"> - 여러 파일을 선택할 수 있습니다. + {t("templateUploadTab.multipleFilesAllowed")} </Label> </> )} @@ -147,24 +154,27 @@ export const FormDataReportTempUploadTab: FC< <div className="grid gap-2"> <div className="flex items-center justify-between"> <h6 className="text-sm font-semibold"> - 선택된 파일 ({selectedFiles.length}) + {t("templateUploadTab.selectedFiles", { count: selectedFiles.length })} </h6> - <Badge variant="secondary">{selectedFiles.length}개 파일</Badge> + <Badge variant="secondary"> + {t("templateUploadTab.fileCount", { count: selectedFiles.length })} + </Badge> </div> <ScrollArea> <UploadFileItem selectedFiles={selectedFiles} removeFile={removeFile} isUploading={isUploading} + t={t} /> </ScrollArea> </div> )} - {isUploading && <UploadProgressBox uploadProgress={uploadProgress} />} + {isUploading && <UploadProgressBox uploadProgress={uploadProgress} t={t} />} <DialogFooter> <Button disabled={selectedFiles.length === 0} onClick={submitData}> - 업로드 + {t("templateUploadTab.upload")} </Button> </DialogFooter> </div> @@ -175,12 +185,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-[150px] gap-3"> @@ -199,7 +211,7 @@ const UploadFileItem: FC<UploadFileItemProps> = ({ disabled={isUploading} > <X className="h-4 w-4" /> - <span className="sr-only">Remove</span> + <span className="sr-only">{t("templateUploadTab.remove")}</span> </FileListAction> </FileListHeader> </FileListItem> @@ -208,14 +220,17 @@ const UploadFileItem: FC<UploadFileItemProps> = ({ ); }; -const UploadProgressBox: FC<{ uploadProgress: number }> = ({ - uploadProgress, -}) => { +const UploadProgressBox: FC<{ + uploadProgress: number; + t: (key: string, options?: any) => string; +}> = ({ uploadProgress, t }) => { return ( <div className="flex flex-col gap-1 mt-2"> <div className="flex items-center gap-2"> <Loader2 className="h-4 w-4 animate-spin" /> - <span className="text-sm">{uploadProgress}% 업로드 중...</span> + <span className="text-sm"> + {t("templateUploadTab.uploadingProgress", { progress: uploadProgress })} + </span> </div> <div className="h-2 w-full bg-muted rounded-full overflow-hidden"> <div |
