From 9e3458481a65bb5572b7f1916e7c068b54a434c5 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Tue, 30 Sep 2025 06:41:26 +0000
Subject: (최겸) 구매 협력업체 정기평가, 가입승인, 기본계약 리비전 등
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/evaluation-submit/evaluation-form.tsx | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'lib/evaluation-submit/evaluation-form.tsx')

diff --git a/lib/evaluation-submit/evaluation-form.tsx b/lib/evaluation-submit/evaluation-form.tsx
index fbdcee69..d51a0369 100644
--- a/lib/evaluation-submit/evaluation-form.tsx
+++ b/lib/evaluation-submit/evaluation-form.tsx
@@ -90,13 +90,15 @@ export function EvaluationForm({ formData, onSubmit }: EvaluationFormProps) {
     questions.forEach(question => {
       const isVariable = question.scoreType === 'variable'
 
+      // 선택된 답변 옵션 찾기
+      const selectedOption = question.selectedDetailId ?
+        question.availableOptions.find(opt => opt.detailId === question.selectedDetailId) : null;
+
       initial[question.criteriaId] = {
         detailId: isVariable ? -1 : question.selectedDetailId,
         score: isVariable ?
-          question.currentScore || null :
-          (question.selectedDetailId ?
-            question.availableOptions.find(opt => opt.detailId === question.selectedDetailId)?.score || question.currentScore || null
-            : question.currentScore || null),
+          (question.currentScore ? Number(question.currentScore) : null) :
+          (selectedOption?.score ?? (question.currentScore ? Number(question.currentScore) : null)),
         comment: question.currentComment || "",
       }
     })
@@ -108,7 +110,7 @@ export function EvaluationForm({ formData, onSubmit }: EvaluationFormProps) {
     console.log('Initializing attachments from server data...')
     const initial: Record<number, AttachmentInfo[]> = {}
     questions.forEach(question => {
-      const questionAttachments = question.attachments || []
+      const questionAttachments = Array.isArray(question.attachments) ? question.attachments : []
       initial[question.criteriaId] = questionAttachments
       if (questionAttachments.length > 0) {
         console.log(`Question ${question.criteriaId} has ${questionAttachments.length} attachments:`, questionAttachments)
-- 
cgit v1.2.3

