import dayjs from "dayjs"; import type { ColumnDef } from "@tanstack/react-table"; import { Button } from "@common/components"; import type { LwpoCode } from "@/entities/code"; import { LwpoCodeManagementDialog } from "../ui/lwpocode-dialog"; import { useState } from "react"; // columns를 함수로 변경하여 onAfterSave를 주입받음 export function getColumns(onAfterSave: () => void) : ColumnDef[] { return [ { id: "no", header: "NO", cell: ({ row, table }) => { const totalRows = table.getRowCount(); const { pageIndex, pageSize } = table.getState().pagination; return totalRows - (pageIndex * pageSize + row.index); }, }, { accessorKey: "lwpoCd", header: "하위코드", }, { accessorKey: "lwpoCdNm", header: "하위코드명", }, { accessorKey: "useYn", header: "사용 여부", }, { accessorKey: "regDt", header: "등록일", cell: ({ row }) => { const date = dayjs(row.original.regDt); return date.format("YYYY-MM-DD"); }, }, { id: "actions", header: "관리", cell: ({ row }) => (
e.stopPropagation()}>
), }, ]; } const LwpoCodeManageButton = ({ lwpoCd, upCd, onAfterSave, }: { lwpoCd: string; upCd: string; onAfterSave: () => void; }) => { const [dialogOpen, setDialogOpen] = useState(false); return ( ); };