File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeaderCell,
TableRow,
} from '@/components/ui/table';
import {
EMPTY_FIELD_PLACEHOLDER,
formatBoardCategoryLabel,
formatOptionalValue,
formatVisibilityLabel,
type BoardPost,
} from '@/lib/domain/board-post';
import { BoardRowActions } from '../../_components/board-row-actions';
interface NoticeTableProps {
items: BoardPost[];
page: number;
pageSize: number;
totalCount: number;
}
const COLUMN_HEADERS = [
'번호',
'구분',
'제목',
'첨부',
'작성자',
'사용여부',
'작성일',
'관리',
];
/**
* 공지사항 목록 테이블 — 시안 A_BOA_006 ③.
*
* "번호"는 저장된 값이 아니라 전체 건수에서 거꾸로 세는 표시 순번이다(시안이 2·1처럼 내림차순으로
* 표기하고 목록이 최신순이라 가장 최근 글이 가장 큰 번호가 된다). 정확한 전체 건수를 전제하는데,
* Repository가 전체를 받아 세기 때문에 그 전제가 성립한다.
*
* "첨부"는 파일 유무만 표시한다 — 백엔드에 atchFileId로 파일 정보를 조회하는 API가 없어 파일명·
* 용량을 알 수 없다(`board-attachment-field.tsx` 주석 참조).
*/
export function NoticeTable({
items,
page,
pageSize,
totalCount,
}: NoticeTableProps) {
const offset = (page - 1) * pageSize;
return (
<Table>
<TableHead>
<TableRow>
{COLUMN_HEADERS.map((header) => (
<TableHeaderCell key={header}>{header}</TableHeaderCell>
))}
</TableRow>
</TableHead>
<TableBody>
{items.map((post, index) => (
<TableRow key={post.id}>
<TableCell>{totalCount - offset - index}</TableCell>
<TableCell>{formatBoardCategoryLabel(post.categoryCode)}</TableCell>
<TableCell>{formatOptionalValue(post.title)}</TableCell>
<TableCell>
{post.attachmentId ? '있음' : EMPTY_FIELD_PLACEHOLDER}
</TableCell>
<TableCell>{formatOptionalValue(post.authorName)}</TableCell>
<TableCell>{formatVisibilityLabel(post.isVisible)}</TableCell>
<TableCell>{formatOptionalValue(post.createdAt)}</TableCell>
<TableCell>
<BoardRowActions boardType="notice" post={post} />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
);
}