From 089c70ffbe2303ab5e2611a152ddd3aed0e6e718 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 1 Sep 2025 09:09:15 +0000
Subject: (최겸) 구매 pq, 기본정보 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/pq-input/pq-review-wrapper.tsx | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

(limited to 'components/pq-input/pq-review-wrapper.tsx')

diff --git a/components/pq-input/pq-review-wrapper.tsx b/components/pq-input/pq-review-wrapper.tsx
index 1056189e..cc0f1b40 100644
--- a/components/pq-input/pq-review-wrapper.tsx
+++ b/components/pq-input/pq-review-wrapper.tsx
@@ -67,6 +67,27 @@ export function PQReviewWrapper({
   const [shiComments, setShiComments] = React.useState<Record<number, string>>({})
   const [isUpdatingComment, setIsUpdatingComment] = React.useState<number | null>(null)
   
+  // 코드 순서로 정렬하는 함수 (1-1-1, 1-1-2, 1-2-1 순서)
+  const sortByCode = (items: any[]) => {
+    return [...items].sort((a, b) => {
+      const parseCode = (code: string) => {
+        return code.split('-').map(part => parseInt(part, 10))
+      }
+      
+      const aCode = parseCode(a.code)
+      const bCode = parseCode(b.code)
+      
+      for (let i = 0; i < Math.max(aCode.length, bCode.length); i++) {
+        const aPart = aCode[i] || 0
+        const bPart = bCode[i] || 0
+        if (aPart !== bPart) {
+          return aPart - bPart
+        }
+      }
+      return 0
+    })
+  }
+  
   // 기존 SHI 코멘트를 로컬 상태에 초기화
   React.useEffect(() => {
     const initialComments: Record<number, string> = {}
@@ -344,7 +365,7 @@ export function PQReviewWrapper({
           <h3 className="text-lg font-medium">{group.groupName}</h3>
           
           <div className="grid grid-cols-1 gap-4">
-            {group.items.map((item) => (
+            {sortByCode(group.items).map((item) => (
               <Card key={item.criteriaId}>
                 <CardHeader>
                   <div className="flex justify-between items-start">
-- 
cgit v1.2.3

