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

---
 .../code-groups/table/code-groups-table.tsx        | 34 ++++++++++++++++++----
 1 file changed, 28 insertions(+), 6 deletions(-)

(limited to 'lib/docu-list-rule/code-groups/table/code-groups-table.tsx')

diff --git a/lib/docu-list-rule/code-groups/table/code-groups-table.tsx b/lib/docu-list-rule/code-groups/table/code-groups-table.tsx
index 8873c34c..0029ed91 100644
--- a/lib/docu-list-rule/code-groups/table/code-groups-table.tsx
+++ b/lib/docu-list-rule/code-groups/table/code-groups-table.tsx
@@ -9,10 +9,10 @@ import type {
   DataTableFilterField,
   DataTableRowAction,
 } from "@/types/table"
-import { getColumns } from "./code-groups-table-columns";
-import { DeleteCodeGroupsDialog } from "./delete-code-groups-dialog";
-import { CodeGroupsEditSheet } from "./code-groups-edit-sheet";
-import { CodeGroupsTableToolbarActions } from "./code-groups-table-toolbar";
+import { getColumns } from "@/lib/docu-list-rule/code-groups/table/code-groups-table-columns";
+import { DeleteCodeGroupsDialog } from "@/lib/docu-list-rule/code-groups/table/delete-code-groups-dialog";
+import { CodeGroupsEditSheet } from "@/lib/docu-list-rule/code-groups/table/code-groups-edit-sheet";
+import { CodeGroupsTableToolbarActions } from "@/lib/docu-list-rule/code-groups/table/code-groups-table-toolbar";
 import { codeGroups } from "@/db/schema/docu-list-rule";
 
 interface CodeGroupsTableProps {
@@ -68,12 +68,34 @@ export function CodeGroupsTable({ promises }: CodeGroupsTableProps) {
       enableAdvancedFilter: true,
       initialState: {
         columnPinning: { right: ["actions"] },
+        expanded: {},
       },
-      getRowId: (originalRow) => String(originalRow.groupId),
+      getRowId: (originalRow) => String(originalRow.id),
       shallow: false,
-      clearOnDefault: true,
+      clearOnDefault: false,
     })
 
+  // 컴포넌트 마운트 후 그룹핑 설정
+  React.useEffect(() => {
+    if (data && table.getState().grouping.length === 0) {
+      table.setGrouping(["projectCode"])
+    }
+  }, [table, data])
+
+  // 정렬 시 펼쳐진 상태 유지
+  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

