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 type { Metadata } from 'next';
import Link from 'next/link';
import { Alert } from '@/components/ui/alert';
import { Pagination } from '@/components/ui/pagination';
import { verifySession } from '@/lib/auth/dal';
import { fetchBoardPosts } from '@/lib/data/repositories/board-post-repository';
import {
buildBoardPostHref,
parseBoardPostQuery,
} from '@/lib/domain/board-post-query';
import { BoardFilterBar } from '../_components/board-filter-bar';
import { BoardListToolbar } from '../_components/board-list-toolbar';
import { FaqTable } from './_components/faq-table';
export const metadata: Metadata = {
title: 'FAQ',
};
interface PageProps {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
/** FAQ 목록 — 시안 A_BOA_014. 구조는 공지사항과 같고 컬럼·필터만 다르다. */
export default async function Page({ searchParams }: PageProps) {
await verifySession();
const query = parseBoardPostQuery('faq', await searchParams);
const { items, totalCount } = await fetchBoardPosts('faq', query);
const totalPages = Math.max(1, Math.ceil(totalCount / query.pageSize));
const currentPage = Math.min(query.page, totalPages);
return (
<section className="flex flex-1 flex-col gap-6 p-8">
<h1 className="text-headline-sm text-foreground">FAQ 목록</h1>
<BoardFilterBar boardType="faq" query={query} />
<BoardListToolbar boardType="faq" query={query} canCreate />
<p className="text-body-md text-foreground-muted">
총 {totalCount}개 | 현재페이지 {currentPage}/{totalPages}
</p>
{items.length === 0 ? (
<Alert
title="검색 결과가 없습니다."
actions={
<Link
href={buildBoardPostHref('faq', query, { keyword: '', page: 1 })}
className="bg-foreground px-4 py-2 text-background"
>
확인
</Link>
}
>
다른 검색어로 다시 시도해 주세요.
</Alert>
) : (
<>
<FaqTable
items={items}
page={currentPage}
pageSize={query.pageSize}
totalCount={totalCount}
/>
<Pagination
currentPage={currentPage}
totalPages={totalPages}
buildHref={(page: number) =>
buildBoardPostHref('faq', query, { page })
}
/>
</>
)}
</section>
);
}