From 67bb1ad7d7e001e19c8d1dd9153a5f663e2afa03 Mon Sep 17 00:00:00 2001
From: 0-Zz-ang <s1998319@gmail.com>
Date: Thu, 7 Aug 2025 18:02:54 +0900
Subject: (박서영)docu-list-rule Project_code적용
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/combo-box-settings-table.tsx             | 25 +++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

(limited to 'lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx')

diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
index 42ce1a19..8e469149 100644
--- a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
+++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx
@@ -5,8 +5,8 @@ import { useDataTable } from "@/hooks/use-data-table"
 import { DataTable } from "@/components/data-table/data-table"
 import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar"
 import type { DataTableAdvancedFilterField } from "@/types/table"
-import { getColumns } from "./combo-box-settings-table-columns"
-import { ComboBoxOptionsDetailSheet } from "./combo-box-options-detail-sheet"
+import { getColumns } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table-columns"
+import { ComboBoxOptionsDetailSheet } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-options-detail-sheet"
 import { codeGroups } from "@/db/schema/docu-list-rule"
 
 interface ComboBoxSettingsTableProps {
@@ -61,11 +61,30 @@ export function ComboBoxSettingsTable({ promises }: ComboBoxSettingsTableProps)
         },
       ],
     },
-    getRowId: (originalRow) => String(originalRow.groupId),
+    getRowId: (originalRow) => String(originalRow.id),
     shallow: false,
     clearOnDefault: true,
   })
 
+  // 컴포넌트 마운트 후 그룹핑 설정
+  React.useEffect(() => {
+    if (rawData[0]?.data && table.getState().grouping.length === 0) {
+      table.setGrouping(["projectCode"])
+    }
+  }, [table, rawData])
+
+  // 정렬 시 펼쳐진 상태 유지
+  React.useEffect(() => {
+    const currentExpanded = table.getState().expanded
+    if (Object.keys(currentExpanded).length > 0) {
+      // 약간의 지연 후 현재 펼쳐진 상태를 다시 설정
+      const timer = setTimeout(() => {
+        table.setExpanded(currentExpanded)
+      }, 100)
+      return () => clearTimeout(timer)
+    }
+  }, [table.getState().sorting, table])
+
   return (
     <>
       <DataTable table={table}>
-- 
cgit v1.2.3

