Files
contact-front/src/app/(pages)/(main)/manage/user/UserTableColumn.tsx

73 lines
1.7 KiB
TypeScript

import {ColumnDef} from "@tanstack/react-table";
import {Button} from "@/components/ui/button";
import {Pencil, Trash2} from "lucide-react";
import {UserTableInfo} from "@/types/user";
export type UserColumnsActions = {
onEdit: (userId: string) => void
onDelete: (userId: string) => void
}
export const getUserColumns = (actions: UserColumnsActions): ColumnDef<UserTableInfo>[] => [
{
accessorKey: "userId",
header: "아이디",
enableSorting: true,
},
{
accessorKey: "userCmpn",
header: "소속",
enableSorting: true,
},
{
accessorKey: "userName",
header: "이름",
enableSorting: true,
},
{
accessorKey: "userRole",
header: "권한",
enableSorting: true,
},
{
accessorKey: "regDt",
header: "등록일",
enableSorting: true,
},
{
accessorKey: "memo",
header: "메모",
enableSorting: false,
},
{
id: "actions",
header: "관리",
cell: ({ row }) => (
<div
className="flex items-center justify-center gap-2"
onClick={(e) => e.stopPropagation()}
onPointerDown={(e) => e.stopPropagation()}
>
<Button
variant="ghost"
size="icon"
onClick={() => actions.onEdit(row.original.userId)}
aria-label="수정"
>
<Pencil className="w-4 h-4" />
</Button>
<Button
variant="ghost"
size="icon"
onClick={() => actions.onDelete(row.original.userId)}
aria-label="삭제"
>
<Trash2 className="w-4 h-4 text-destructive" />
</Button>
</div>
),
enableSorting: false,
},
];