From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 28 Apr 2025 02:13:30 +0000
Subject: ~20250428 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/candidates-table-columns.tsx             | 104 +++++++++++----------
 1 file changed, 55 insertions(+), 49 deletions(-)

(limited to 'lib/vendor-candidates/table/candidates-table-columns.tsx')

diff --git a/lib/vendor-candidates/table/candidates-table-columns.tsx b/lib/vendor-candidates/table/candidates-table-columns.tsx
index dc014d4e..113927cf 100644
--- a/lib/vendor-candidates/table/candidates-table-columns.tsx
+++ b/lib/vendor-candidates/table/candidates-table-columns.tsx
@@ -7,7 +7,7 @@ import { Ellipsis } from "lucide-react"
 import { toast } from "sonner"
 
 import { getErrorMessage } from "@/lib/handle-error"
-import { formatDate } from "@/lib/utils"
+import { formatDate, formatDateTime } from "@/lib/utils"
 import { Badge } from "@/components/ui/badge"
 import { Button } from "@/components/ui/button"
 import { Checkbox } from "@/components/ui/checkbox"
@@ -24,24 +24,24 @@ import {
   DropdownMenuSubTrigger,
   DropdownMenuTrigger,
 } from "@/components/ui/dropdown-menu"
-import { DataTableColumnHeader } from "@/components/data-table/data-table-column-header"
 
-import { VendorCandidates, vendorCandidates } from "@/db/schema/vendors"
 import { getCandidateStatusIcon } from "@/lib/vendor-candidates/utils"
 import { candidateColumnsConfig } from "@/config/candidatesColumnsConfig"
+import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"
+import { VendorCandidatesWithVendorInfo } from "@/db/schema"
 
 interface GetColumnsProps {
-  setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<VendorCandidates> | null>>
+  setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<VendorCandidatesWithVendorInfo> | null>>
 }
 
 /**
  * tanstack table 컬럼 정의 (중첩 헤더 버전)
  */
-export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<VendorCandidates>[] {
+export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<VendorCandidatesWithVendorInfo>[] {
   // ----------------------------------------------------------------
   // 1) select 컬럼 (체크박스)
   // ----------------------------------------------------------------
-  const selectColumn: ColumnDef<VendorCandidates> = {
+  const selectColumn: ColumnDef<VendorCandidatesWithVendorInfo> = {
     id: "select",
     header: ({ table }) => (
       <Checkbox
@@ -70,48 +70,54 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<VendorC
   // ----------------------------------------------------------------
   // 2) actions 컬럼 (Dropdown 메뉴)
   // ----------------------------------------------------------------
-  const actionsColumn: ColumnDef<VendorCandidates> = {
-    id: "actions",
-    enableHiding: false,
-    cell: function Cell({ row }) {
-      const [isUpdatePending, startUpdateTransition] = React.useTransition()
-
-      return (
-        <DropdownMenu>
-          <DropdownMenuTrigger asChild>
-            <Button
-              aria-label="Open menu"
-              variant="ghost"
-              className="flex size-8 p-0 data-[state=open]:bg-muted"
-            >
-              <Ellipsis className="size-4" aria-hidden="true" />
-            </Button>
-          </DropdownMenuTrigger>
-          <DropdownMenuContent align="end" className="w-40">
-            <DropdownMenuItem
-              onSelect={() => setRowAction({ row, type: "update" })}
-            >
-              Edit
-            </DropdownMenuItem>
-
-            <DropdownMenuItem
-              onSelect={() => setRowAction({ row, type: "delete" })}
-            >
-              Delete
-              <DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
-            </DropdownMenuItem>
-          </DropdownMenuContent>
-        </DropdownMenu>
-      )
-    },
-    size: 40,
-  }
+// "actions" 컬럼 예시
+const actionsColumn: ColumnDef<VendorCandidatesWithVendorInfo> = {
+  id: "actions",
+  enableHiding: false,
+  cell: function Cell({ row }) {
+    return (
+      <DropdownMenu>
+        <DropdownMenuTrigger asChild>
+          <Button
+            aria-label="Open menu"
+            variant="ghost"
+            className="flex size-8 p-0 data-[state=open]:bg-muted"
+          >
+            <Ellipsis className="size-4" aria-hidden="true" />
+          </Button>
+        </DropdownMenuTrigger>
+        <DropdownMenuContent align="end" className="w-40">
+          <DropdownMenuItem
+            onSelect={() => setRowAction({ row, type: "update" })}
+          >
+            편집
+          </DropdownMenuItem>
+          <DropdownMenuItem
+            onSelect={() => setRowAction({ row, type: "delete" })}
+          >
+            삭제
+            <DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
+          </DropdownMenuItem>
+
+          {/* 여기서 Log 보기 액션 추가 */}
+          <DropdownMenuItem
+            onSelect={() => setRowAction({ row, type: "log" })}
+          >
+            감사 로그 보기
+          </DropdownMenuItem>
+        </DropdownMenuContent>
+      </DropdownMenu>
+    )
+  },
+  size: 40,
+}
+
 
   // ----------------------------------------------------------------
   // 3) 일반 컬럼들을 "그룹"별로 묶어 중첩 columns 생성
   // ----------------------------------------------------------------
-  // 3-1) groupMap: { [groupName]: ColumnDef<VendorCandidates>[] }
-  const groupMap: Record<string, ColumnDef<VendorCandidates>[]> = {}
+  // 3-1) groupMap: { [groupName]: ColumnDef<VendorCandidatesWithVendorInfo>[] }
+  const groupMap: Record<string, ColumnDef<VendorCandidatesWithVendorInfo>[]> = {}
 
   candidateColumnsConfig.forEach((cfg) => {
     // 만약 group가 없으면 "_noGroup" 처리
@@ -122,11 +128,11 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<VendorC
     }
 
     // child column 정의
-    const childCol: ColumnDef<VendorCandidates> = {
+    const childCol: ColumnDef<VendorCandidatesWithVendorInfo> = {
       accessorKey: cfg.id,
       enableResizing: true,
       header: ({ column }) => (
-        <DataTableColumnHeader column={column} title={cfg.label} />
+        <DataTableColumnHeaderSimple column={column} title={cfg.label} />
       ),
       meta: {
         excelHeader: cfg.excelHeader,
@@ -148,9 +154,9 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<VendorC
         }
 
 
-        if (cfg.id === "createdAt") {
+        if (cfg.id === "createdAt" ||cfg.id === "updatedAt" ) {
           const dateVal = cell.getValue() as Date
-          return formatDate(dateVal)
+          return formatDateTime(dateVal)
         }
 
         // code etc...
@@ -164,7 +170,7 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<VendorC
   // ----------------------------------------------------------------
   // 3-2) groupMap에서 실제 상위 컬럼(그룹)을 만들기
   // ----------------------------------------------------------------
-  const nestedColumns: ColumnDef<VendorCandidates>[] = []
+  const nestedColumns: ColumnDef<VendorCandidatesWithVendorInfo>[] = []
 
   // 순서를 고정하고 싶다면 group 순서를 미리 정의하거나 sort해야 함
   // 여기서는 그냥 Object.entries 순서
-- 
cgit v1.2.3

