diff options
Diffstat (limited to 'lib/basic-contract/template/add-basic-contract-template-dialog.tsx')
| -rw-r--r-- | lib/basic-contract/template/add-basic-contract-template-dialog.tsx | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/basic-contract/template/add-basic-contract-template-dialog.tsx b/lib/basic-contract/template/add-basic-contract-template-dialog.tsx index fd1bd333..6b6ab105 100644 --- a/lib/basic-contract/template/add-basic-contract-template-dialog.tsx +++ b/lib/basic-contract/template/add-basic-contract-template-dialog.tsx @@ -219,16 +219,21 @@ export function AddTemplateDialog() { setIsLoading(true);
try {
let uploadResult = null;
-
+
+ // ๐ ํ์ผ ์
๋ก๋๊ฐ ํ์ํ ๊ฒฝ์ฐ์๋ง ์
๋ก๋ ์งํ
if (formData.file) {
const fileId = uuidv4();
uploadResult = await uploadFileInChunks(formData.file, fileId);
-
+
if (!uploadResult?.success) {
throw new Error("ํ์ผ ์
๋ก๋์ ์คํจํ์ต๋๋ค.");
}
}
-
+
+ // ๐ General GTC์ด๊ณ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ์ ๋ค๋ฅธ ๊ฒฝ์ฐ ๊ตฌ๋ถ ์ฒ๋ฆฌ
+ const isGeneralGTC = formData.templateName === "General GTC";
+ const hasFile = uploadResult && uploadResult.success;
+
const saveResponse = await fetch('/api/upload/basicContract/complete', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -245,17 +250,28 @@ export function AddTemplateDialog() { sysApplicable: formData.sysApplicable,
infraApplicable: formData.infraApplicable,
status: "ACTIVE",
- fileName: uploadResult?.fileName || `${formData.templateName}_v1.docx`,
- filePath: uploadResult?.filePath || "",
+
+ // ๐ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ์๋ง fileName๊ณผ filePath ์ ์ก
+ ...(hasFile && {
+ fileName: uploadResult.fileName,
+ filePath: uploadResult.filePath,
+ }),
+
+ // ๐ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ null ์ ์ก (์คํค๋ง๊ฐ nullable์ด์ด์ผ ํจ)
+ ...(!hasFile && {
+ fileName: null,
+ filePath: null,
+ })
}),
next: { tags: ["basic-contract-templates"] },
});
-
+
const saveResult = await saveResponse.json();
if (!saveResult.success) {
+ console.log(saveResult.error);
throw new Error(saveResult.error || "ํ
ํ๋ฆฟ ์ ๋ณด ์ ์ฅ์ ์คํจํ์ต๋๋ค.");
}
-
+
toast.success('ํ
ํ๋ฆฟ์ด ์ฑ๊ณต์ ์ผ๋ก ์ถ๊ฐ๋์์ต๋๋ค.');
form.reset();
setSelectedFile(null);
|
