From 5cb225e9cd6b0ba2f52572a3afa0de6e5b2a2ece Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Fri, 18 Jul 2025 16:32:22 +0900
Subject: 파일첨부 API 처리, 텍스트 변경
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/knox/approval/ApprovalSubmit.tsx | 46 ++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 7 deletions(-)

(limited to 'components/knox/approval/ApprovalSubmit.tsx')

diff --git a/components/knox/approval/ApprovalSubmit.tsx b/components/knox/approval/ApprovalSubmit.tsx
index 37779ce3..526a87f3 100644
--- a/components/knox/approval/ApprovalSubmit.tsx
+++ b/components/knox/approval/ApprovalSubmit.tsx
@@ -17,7 +17,7 @@ import { toast } from 'sonner';
 import { Loader2, Plus, Trash2, FileText, AlertCircle } from 'lucide-react';
 
 // API 함수 및 타입
-import { submitApproval, createSubmitApprovalRequest, createApprovalLine } from '@/lib/knox-api/approval/approval';
+import { submitApproval, submitSecurityApproval, createSubmitApprovalRequest, createApprovalLine } from '@/lib/knox-api/approval/approval';
 import type { ApprovalLine, SubmitApprovalRequest } from '@/lib/knox-api/approval/approval';
 
 // Mock 데이터
@@ -40,7 +40,9 @@ const formSchema = z.object({
     role: z.enum(['0', '1', '2', '3', '4', '7', '9']),
     seq: z.string(),
     opinion: z.string().optional()
-  })).min(1, '최소 1개의 결재 경로가 필요합니다')
+  })).min(1, '최소 1개의 결재 경로가 필요합니다'),
+  // 첨부파일 (선택)
+  attachments: z.any().optional()
 });
 
 type FormData = z.infer<typeof formSchema>;
@@ -80,7 +82,8 @@ export default function ApprovalSubmit({
           seq: '1',
           opinion: ''
         }
-      ]
+      ],
+      attachments: undefined
     }
   });
 
@@ -137,6 +140,8 @@ export default function ApprovalSubmit({
       );
 
       // 상신 요청 생성
+      const attachmentsArray = data.attachments ? Array.from(data.attachments as FileList) : undefined;
+
       const submitRequest: SubmitApprovalRequest = useFakeData
         ? {
             ...data,
@@ -144,7 +149,8 @@ export default function ApprovalSubmit({
             importantYn: data.importantYn ? 'Y' : 'N',
             sbmDt: new Date().toISOString().replace(/-|:|T/g, '').slice(0, 14),
             apInfId: 'test-ap-inf-id-' + Date.now(),
-            aplns: approvalLines
+            aplns: approvalLines,
+            attachments: attachmentsArray
           }
         : await createSubmitApprovalRequest(
             data.contents,
@@ -158,14 +164,19 @@ export default function ApprovalSubmit({
               notifyOption: data.notifyOption,
               docMngSaveCode: data.docMngSaveCode,
               sbmLang: data.sbmLang,
-              timeZone: data.timeZone
+              timeZone: data.timeZone,
+              attachments: attachmentsArray
             }
           );
 
-      // API 호출
+      // API 호출 (보안 등급에 따라 분기)
+      const isSecure = data.docSecuType === 'CONFIDENTIAL' || data.docSecuType === 'CONFIDENTIAL_STRICT';
+
       const response = useFakeData
         ? await mockApprovalAPI.submitApproval(submitRequest)
-        : await submitApproval(submitRequest, systemId);
+        : isSecure
+          ? await submitSecurityApproval(submitRequest, systemId)
+          : await submitApproval(submitRequest, systemId);
 
       if (response.result === 'SUCCESS') {
         setSubmitResult({ apInfId: response.data.apInfId });
@@ -333,6 +344,27 @@ export default function ApprovalSubmit({
                   )}
                 />
               </div>
+
+              {/* 첨부 파일 */}
+              <FormField
+                control={form.control}
+                name="attachments"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>첨부 파일</FormLabel>
+                    <FormControl>
+                      <Input
+                        type="file"
+                        multiple
+                        onChange={(e) => field.onChange(e.target.files)}
+                      />
+                    </FormControl>
+                    <FormDescription>필요 시 파일을 선택하세요. (다중 선택 가능)</FormDescription>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+
             </div>
 
             <Separator />
-- 
cgit v1.2.3

