import dayjs from "dayjs"; import type { ColumnDef } from "@tanstack/react-table"; import { USER_STATE_CODE, type UserListResponse, type UserStateCode, } from "@/entities/user"; import { Badge } from "@common/components"; export const columns: ColumnDef[] = [ { id: "no", header: "No", cell: ({ row, table }) => { const totalRows = table.getRowCount(); const currentPage = table.getState().pagination.pageIndex; const pageSize = table.getState().pagination.pageSize; return totalRows - (currentPage * pageSize + row.index); }, }, { accessorKey: "userId", header: "아이디", }, { accessorKey: "userName", header: "이름", }, { accessorKey: "telno", header: "전화번호", }, { accessorKey: "email", header: "이메일", }, { accessorKey: "laeSeNm", header: "구분", }, { accessorKey: "ogdpSeNm", header: "소속", }, { accessorKey: "instSeNm", header: "기관/부서", }, { accessorKey: "userStateCode", header: "회원상태", cell: ({ row }) => { return getUserStateBadge(row.original.userStateCode); }, }, { accessorKey: "aprvYmd", header: "승인일자", }, { accessorKey: "loginFailCount", header: "로그인실패횟수", }, { accessorKey: "lastLoginDate", header: "최종접속일", cell: ({ row }) => { return row.original.lastLoginDate ? dayjs(row.original.lastLoginDate).format("YYYY-MM-DD") : ""; }, }, ]; const getUserStateBadge = (userStateCode: UserStateCode) => { switch (userStateCode) { case USER_STATE_CODE.대기: return 대기; case USER_STATE_CODE.정상: return 정상; case USER_STATE_CODE.정지: return 정지; case USER_STATE_CODE.탈퇴: return 탈퇴; case USER_STATE_CODE.삭제: return 삭제; } };