89 lines
2.0 KiB
TypeScript
89 lines
2.0 KiB
TypeScript
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<UserListResponse>[] = [
|
|
{
|
|
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 <Badge color="gray">대기</Badge>;
|
|
case USER_STATE_CODE.정상:
|
|
return <Badge color="green">정상</Badge>;
|
|
case USER_STATE_CODE.정지:
|
|
return <Badge color="yellow">정지</Badge>;
|
|
case USER_STATE_CODE.탈퇴:
|
|
return <Badge color="purple">탈퇴</Badge>;
|
|
case USER_STATE_CODE.삭제:
|
|
return <Badge color="red">삭제</Badge>;
|
|
}
|
|
};
|