From 26bd5a0af8f69fd693c16d2eacb35cf138a360d1 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Wed, 10 Sep 2025 08:59:19 +0000
Subject: (김준회) 결재 이력조회 기능 추가 및 로그 테이블 확장, 테스트모듈 작성
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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

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

diff --git a/lib/approval-log/table/approval-log-table.tsx b/lib/approval-log/table/approval-log-table.tsx
new file mode 100644
index 00000000..75955ec6
--- /dev/null
+++ b/lib/approval-log/table/approval-log-table.tsx
@@ -0,0 +1,107 @@
+"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,
+} from '@/types/table';
+
+import { getColumns } from './approval-log-table-column';
+import { getApprovalLogList } from '../service';
+import { type ApprovalLog } from '../service';
+
+interface ApprovalLogTableProps {
+  promises: Promise<[
+    Awaited<ReturnType<typeof getApprovalLogList>>,
+  ]>;
+}
+
+type ApprovalLogRowAction = {
+  type: "view";
+  row: { original: ApprovalLog };
+} | null;
+
+export function ApprovalLogTable({ promises }: ApprovalLogTableProps) {
+  const [{ data, pageCount }] = React.use(promises);
+
+  const setRowAction = React.useState<ApprovalLogRowAction>(null)[1];
+
+  const columns = React.useMemo(
+    () => getColumns({ setRowAction }),
+    [setRowAction]
+  );
+
+  // 기본 & 고급 필터 필드
+  const filterFields: DataTableFilterField<ApprovalLog>[] = [];
+  const advancedFilterFields: DataTableAdvancedFilterField<ApprovalLog>[] = [
+    {
+      id: 'subject',
+      label: '결재 제목',
+      type: 'text',
+    },
+    {
+      id: 'status',
+      label: '상태',
+      type: 'text',
+    },
+    {
+      id: 'userId',
+      label: '사용자 ID',
+      type: 'text',
+    },
+    {
+      id: 'emailAddress',
+      label: '이메일',
+      type: 'text',
+    },
+    {
+      id: 'urgYn',
+      label: '긴급여부',
+      type: 'text',
+    },
+    {
+      id: 'docSecuType',
+      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: 'createdAt', desc: true }],
+      columnPinning: { right: ['actions'] },
+    },
+    getRowId: (row) => row.apInfId,
+    shallow: false,
+    clearOnDefault: true,
+  });
+
+  return (
+    <DataTable table={table}>
+      <DataTableAdvancedToolbar
+        table={table}
+        filterFields={advancedFilterFields}
+        shallow={false}
+      />
+    </DataTable>
+  );
+}
-- 
cgit v1.2.3

