76 lines
1.8 KiB
TypeScript
76 lines
1.8 KiB
TypeScript
import dayjs from "dayjs";
|
|
import type { ColumnDef } from "@tanstack/react-table";
|
|
import { Badge } from "@common/components";
|
|
import type { Post, MyPost } from "@/entities/post";
|
|
|
|
const noticePostTableColumns: ColumnDef<Post>[] = [
|
|
{
|
|
header: "번호",
|
|
cell: ({ row, table }) => {
|
|
if (row.original.upndFixYn === "Y") {
|
|
return (
|
|
<Badge
|
|
color="orange"
|
|
className="flex size-8 items-center justify-center"
|
|
>
|
|
<i className="diveicon di-volume-up-fill" />
|
|
</Badge>
|
|
);
|
|
}
|
|
const totalRows = table.getRowCount();
|
|
const currentPage = table.getState().pagination.pageIndex;
|
|
const pageSize = table.getState().pagination.pageSize;
|
|
return totalRows - (currentPage * pageSize + row.index);
|
|
},
|
|
},
|
|
{
|
|
accessorKey: "pstTtl",
|
|
header: "제목",
|
|
},
|
|
{
|
|
accessorKey: "wrtrNm",
|
|
header: "작성자",
|
|
},
|
|
{
|
|
accessorKey: "regDt",
|
|
header: "작성일",
|
|
cell: ({ row }) => dayjs(row.original.regDt).format("YYYY-MM-DD"),
|
|
},
|
|
{
|
|
accessorKey: "inqNocs",
|
|
header: "조회수",
|
|
},
|
|
];
|
|
|
|
const myPostTableColumns: ColumnDef<MyPost>[] = [
|
|
{
|
|
header: "번호",
|
|
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: "pstTtl",
|
|
header: "제목",
|
|
},
|
|
{
|
|
accessorKey: "wrtrNm",
|
|
header: "작성자",
|
|
},
|
|
{
|
|
accessorKey: "regDt",
|
|
header: "작성일",
|
|
cell: ({ row }) => dayjs(row.original.regDt).format("YYYY-MM-DD"),
|
|
},
|
|
{
|
|
accessorKey: "inqNocs",
|
|
header: "조회수",
|
|
},
|
|
];
|
|
|
|
|
|
export { noticePostTableColumns, myPostTableColumns };
|