60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
"use client";
|
|
|
|
import { useRouter } from "next/navigation";
|
|
|
|
import { getCoreRowModel } from "@tanstack/react-table";
|
|
|
|
import { AS_DASHBOARD_BBS_ID } from "@/shared/config";
|
|
import { useDataTable } from "@/shared/lib";
|
|
import { type UserPost, type UserPostSearchParams, useUserPostList } from "@/entities/board";
|
|
import { Button } from "@common/components";
|
|
|
|
import { dashboardNoticeColumns } from "../model/dashboard-notice-table-columns";
|
|
|
|
const DASHBOARD_NOTICE_LIST_PARAMS: UserPostSearchParams = {
|
|
page: 0,
|
|
size: 3,
|
|
keywordType: "bbsTypeCd",
|
|
keyword: "BBSNOTICE",
|
|
};
|
|
|
|
export function DashboardNoticeTable() {
|
|
const router = useRouter();
|
|
const userPostListQuery = useUserPostList(DASHBOARD_NOTICE_LIST_PARAMS);
|
|
|
|
const handleRowClick = (post: UserPost) => {
|
|
if (!AS_DASHBOARD_BBS_ID) return;
|
|
router.push(`/cms/bbsnotice/${AS_DASHBOARD_BBS_ID}/${post.pstNo}`);
|
|
};
|
|
|
|
const handleMoreClick = () => {
|
|
if (!AS_DASHBOARD_BBS_ID) return;
|
|
router.push(`/cms/bbsnotice/${AS_DASHBOARD_BBS_ID}`);
|
|
};
|
|
|
|
const { tableComponent } = useDataTable({
|
|
query: userPostListQuery,
|
|
tableOptions: {
|
|
columns: dashboardNoticeColumns,
|
|
getCoreRowModel: getCoreRowModel(),
|
|
},
|
|
dataTableOptions: {
|
|
caption: "공지사항 목록으로 번호, 제목, 작성자, 작성일, 조회수 정보 제공",
|
|
variant: "line",
|
|
onRowClick: handleRowClick,
|
|
},
|
|
});
|
|
|
|
return (
|
|
<section className="card card-border m-0">
|
|
<div className="card-header flex items-center justify-between">
|
|
<h3 className="text-2xl font-semibold">공지사항</h3>
|
|
<Button type="button" size="sm" color="white" className="!text-[#0056B3]" onClick={handleMoreClick}>
|
|
더보기
|
|
</Button>
|
|
</div>
|
|
{tableComponent}
|
|
</section>
|
|
);
|
|
}
|