From 2b490956c9752c1b756780a3461bc1c37b6fe0a7 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Mon, 15 Sep 2025 18:58:07 +0900 Subject: (김준회) AVL 관리 및 상세 - 기능 구현 1차 + docker compose 내 오류 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/avl/table/columns-detail.tsx | 516 +++++---------------------------------- 1 file changed, 63 insertions(+), 453 deletions(-) (limited to 'lib/avl/table/columns-detail.tsx') diff --git a/lib/avl/table/columns-detail.tsx b/lib/avl/table/columns-detail.tsx index 204d34f5..84ad9d9a 100644 --- a/lib/avl/table/columns-detail.tsx +++ b/lib/avl/table/columns-detail.tsx @@ -1,28 +1,8 @@ import { Checkbox } from "@/components/ui/checkbox" import { Badge } from "@/components/ui/badge" -import { Button } from "@/components/ui/button" -import { Edit, Trash2 } from "lucide-react" -import { type ColumnDef, TableMeta } from "@tanstack/react-table" +import { type ColumnDef } from "@tanstack/react-table" import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" -import { EditableCell } from "@/components/data-table/editable-cell" -// 수정 여부 확인 헬퍼 함수 -const getIsModified = (table: any, rowId: string, fieldName: string) => { - const pendingChanges = table.options.meta?.getPendingChanges?.() || {} - return String(rowId) in pendingChanges && fieldName in pendingChanges[String(rowId)] -} - -// 테이블 메타 타입 확장 -declare module "@tanstack/react-table" { - interface TableMeta { - onCellUpdate?: (id: string, field: keyof TData, newValue: any) => Promise - onCellCancel?: (id: string, field: keyof TData) => void - onAction?: (action: string, data?: any) => void - onSaveEmptyRow?: (tempId: string) => Promise - onCancelEmptyRow?: (tempId: string) => void - isEmptyRow?: (id: string) => boolean - } -} // AVL 상세 아이템 타입 export type AvlDetailItem = { @@ -89,29 +69,6 @@ export const columns: ColumnDef[] = [ { header: "기본 정보", columns: [ - { - id: "select", - header: ({ table }) => ( - table.toggleAllPageRowsSelected(!!value)} - aria-label="Select all" - /> - ), - cell: ({ row }) => ( - row.toggleSelected(!!value)} - aria-label="Select row" - /> - ), - enableSorting: false, - enableHiding: false, - size: 50, - }, { accessorKey: "no", header: ({ column }) => ( @@ -124,33 +81,12 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { + cell: ({ row }) => { const value = row.getValue("equipBulkDivision") as string - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "equipBulkDivision", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "equipBulkDivision") - return ( - + + {value || "-"} + ) }, size: 120, @@ -160,31 +96,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("disciplineName") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "disciplineName", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "disciplineName") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("disciplineName") as string + return {value || "-"} }, size: 120, }, @@ -193,31 +107,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("materialNameCustomerSide") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "materialNameCustomerSide", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "materialNameCustomerSide") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("materialNameCustomerSide") as string + return {value || "-"} }, size: 150, }, @@ -226,31 +118,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("packageName") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "packageName", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "packageName") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("packageName") as string + return {value || "-"} }, size: 130, }, @@ -259,31 +129,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("materialGroupCode") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "materialGroupCode", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "materialGroupCode") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("materialGroupCode") as string + return {value || "-"} }, size: 120, }, @@ -292,31 +140,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("materialGroupName") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "materialGroupName", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "materialGroupName") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("materialGroupName") as string + return {value || "-"} }, size: 130, }, @@ -325,31 +151,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("vendorCode") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "vendorCode", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "vendorCode") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("vendorCode") as string + return {value || "-"} }, size: 120, }, @@ -358,31 +162,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("vendorName") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "vendorName", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "vendorName") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("vendorName") as string + return {value || "-"} }, size: 140, }, @@ -391,31 +173,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("avlVendorName") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "avlVendorName", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "avlVendorName") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("avlVendorName") as string + return {value || "-"} }, size: 140, }, @@ -424,34 +184,20 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { + cell: ({ row }) => { const value = row.getValue("tier") as string - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "tier", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "tier") - + if (!value) return - + + const tierColor = { + "Tier 1": "bg-green-100 text-green-800", + "Tier 2": "bg-yellow-100 text-yellow-800", + "Tier 3": "bg-red-100 text-red-800" + }[value] || "bg-gray-100 text-gray-800" + return ( - + + {value} + ) }, size: 100, @@ -467,28 +213,12 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { + cell: ({ row }) => { const value = row.getValue("faTarget") as boolean - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "faTarget", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "faTarget") - return ( - + + {value ? "대상" : "비대상"} + ) }, size: 80, @@ -498,31 +228,9 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row, table }) => { - const value = row.getValue("faStatus") - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "faStatus", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "faStatus") - - return ( - - ) + cell: ({ row }) => { + const value = row.getValue("faStatus") as string + return {value || "-"} }, size: 100, }, @@ -535,27 +243,13 @@ export const columns: ColumnDef[] = [ { accessorKey: "shiAvl", header: "AVL", - cell: ({ row, table }) => { + cell: ({ row }) => { const value = row.getValue("shiAvl") as boolean - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "shiAvl", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "shiAvl") - return ( - ) }, @@ -564,27 +258,13 @@ export const columns: ColumnDef[] = [ { accessorKey: "shiBlacklist", header: "Blacklist", - cell: ({ row, table }) => { + cell: ({ row }) => { const value = row.getValue("shiBlacklist") as boolean - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "shiBlacklist", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "shiBlacklist") - return ( - ) }, @@ -593,27 +273,13 @@ export const columns: ColumnDef[] = [ { accessorKey: "shiBcc", header: "BCC", - cell: ({ row, table }) => { + cell: ({ row }) => { const value = row.getValue("shiBcc") as boolean - const isEmptyRow = String(row.original.id).startsWith('temp-') - - const onSave = async (newValue: any) => { - if (table.options.meta?.onCellUpdate) { - await table.options.meta.onCellUpdate(row.original.id, "shiBcc", newValue) - } - } - - const isModified = getIsModified(table, row.original.id, "shiBcc") - return ( - ) }, @@ -621,60 +287,4 @@ export const columns: ColumnDef[] = [ }, ], }, - // 액션 컬럼 - { - id: "actions", - header: "액션", - cell: ({ row, table }) => { - const isEmptyRow = String(row.original.id).startsWith('temp-') - - return ( -
- {!isEmptyRow && ( - <> - - - - )} - {isEmptyRow && ( - <> - - - - )} -
- ) - }, - size: 100, - enableSorting: false, - enableHiding: false, - }, ] -- cgit v1.2.3