From bcd462d6e60871b86008e072f4b914138fc5c328 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Mon, 11 Aug 2025 09:34:40 +0000
Subject: (김준회) 리치텍스트에디터 (결재템플릿을 위한 공통컴포넌트),
 command-menu 에러 수정, 결재 템플릿 관리, 결재선 관리, ECC RFQ+PR Item 수신시
 비즈니스테이블(ProcurementRFQ) 데이터 적재, WSDL 오류 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/approval-line/table/approval-line-table.tsx | 130 ++++++++++++++++++++++++
 1 file changed, 130 insertions(+)
 create mode 100644 lib/approval-line/table/approval-line-table.tsx

(limited to 'lib/approval-line/table/approval-line-table.tsx')

diff --git a/lib/approval-line/table/approval-line-table.tsx b/lib/approval-line/table/approval-line-table.tsx
new file mode 100644
index 00000000..21b9972c
--- /dev/null
+++ b/lib/approval-line/table/approval-line-table.tsx
@@ -0,0 +1,130 @@
+"use client";
+
+import * as React from 'react';
+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,
+  DataTableFilterField,
+  DataTableRowAction,
+} from '@/types/table';
+
+import { getColumns } from './approval-line-table-columns';
+import { getApprovalLineList } from '../service';
+import { type ApprovalLine } from '../service';
+import { ApprovalLineTableToolbarActions } from './approval-line-table-toolbar-actions';
+import { CreateApprovalLineSheet } from './create-approval-line-sheet';
+import { UpdateApprovalLineSheet } from './update-approval-line-sheet';
+import { DuplicateApprovalLineSheet } from './duplicate-approval-line-sheet';
+import { DeleteApprovalLineDialog } from './delete-approval-line-dialog';
+
+interface ApprovalLineTableProps {
+  promises: Promise<[
+    Awaited<ReturnType<typeof getApprovalLineList>>,
+  ]>;
+}
+
+export function ApprovalLineTable({ promises }: ApprovalLineTableProps) {
+  const [{ data, pageCount }] = React.use(promises);
+
+  const [rowAction, setRowAction] = 
+    React.useState<DataTableRowAction<ApprovalLine> | null>(null);
+
+  const [showCreateSheet, setShowCreateSheet] = React.useState(false);
+
+  const columns = React.useMemo(
+    () => getColumns({ setRowAction }),
+    [setRowAction]
+  );
+
+  // 기본 & 고급 필터 필드
+  const filterFields: DataTableFilterField<ApprovalLine>[] = [];
+  const advancedFilterFields: DataTableAdvancedFilterField<ApprovalLine>[] = [
+    {
+      id: 'name',
+      label: '결재선 이름',
+      type: 'text',
+    },
+    {
+      id: 'description',
+      label: '설명',
+      type: 'text',
+    },
+    {
+      id: 'createdAt',
+      label: '생성일',
+      type: 'date',
+    },
+    {
+      id: 'updatedAt',
+      label: '수정일',
+      type: 'date',
+    },
+  ];
+
+  const { table } = useDataTable({
+    data,
+    columns,
+    pageCount,
+    filterFields,
+    enablePinning: true,
+    enableAdvancedFilter: true,
+    initialState: {
+      sorting: [{ id: 'updatedAt', desc: true }],
+      columnPinning: { right: ['actions'] },
+    },
+    getRowId: (row) => String(row.id),
+    shallow: false,
+    clearOnDefault: true,
+  });
+
+  return (
+    <>
+      <DataTable table={table}>
+        <DataTableAdvancedToolbar
+          table={table}
+          filterFields={advancedFilterFields}
+          shallow={false}
+        >
+          <ApprovalLineTableToolbarActions
+            table={table}
+            onCreateLine={() => setShowCreateSheet(true)}
+          />
+        </DataTableAdvancedToolbar>
+      </DataTable>
+
+      {/* 새 결재선 생성 Sheet */}
+      <CreateApprovalLineSheet
+        open={showCreateSheet}
+        onOpenChange={setShowCreateSheet}
+      />
+
+      {/* 결재선 수정 Sheet */}
+      <UpdateApprovalLineSheet
+        open={rowAction?.type === "update"}
+        onOpenChange={() => setRowAction(null)}
+        line={rowAction?.type === "update" ? rowAction.row.original : null}
+      />
+
+      {/* 결재선 복제 Sheet */}
+      <DuplicateApprovalLineSheet
+        open={rowAction?.type === "duplicate"}
+        onOpenChange={() => setRowAction(null)}
+        line={rowAction?.type === "duplicate" ? rowAction.row.original : null}
+      />
+
+      {/* 결재선 삭제 Dialog */}
+      <DeleteApprovalLineDialog
+        open={rowAction?.type === "delete"}
+        onOpenChange={() => setRowAction(null)}
+        lines={rowAction?.type === "delete" ? [rowAction.row.original] : []}
+        showTrigger={false}
+        onSuccess={() => {
+          setRowAction(null)
+          // 테이블 새로고침은 server action에서 자동으로 처리됨
+        }}
+      />
+    </>
+  );
+} 
\ No newline at end of file
-- 
cgit v1.2.3

