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 { verifySession } from '@/lib/auth/dal';
import { fetchCommonCodes } from '@/lib/data/repositories/common-code-repository';
import { fetchMerchants } from '@/lib/data/repositories/merchant-repository';
import { CODE_GROUP } from '@/lib/domain/common-code';
import type { MerchantCodeTables } from '@/lib/domain/merchant';
import { parseMerchantQuery } from '@/lib/domain/merchant-query';
import { MerchantList } from './_components/merchant-list';
export const metadata: Metadata = {
title: '가맹몰 관리',
};
export const dynamic = 'force-dynamic';
interface PageProps {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}
export default async function Page({ searchParams }: PageProps) {
await verifySession();
const query = parseMerchantQuery(await searchParams);
const [{ items, totalCount }, business, businessDetail, businessStatus, division, bank] =
await Promise.all([
fetchMerchants(query),
fetchCommonCodes(CODE_GROUP.merchantBusiness),
fetchCommonCodes(CODE_GROUP.merchantBusinessDetail),
fetchCommonCodes(CODE_GROUP.merchantBusinessStatus),
fetchCommonCodes(CODE_GROUP.merchantDivision),
fetchCommonCodes(CODE_GROUP.bank),
]);
const codeTables: MerchantCodeTables = {
// 앞쪽 표가 먼저 맞는다 — 2자리 값은 FRCS_TPBIZ_CD에서, 4자리 값은 FRCS_CD에서 이름을 찾는다.
business: [...business, ...businessDetail],
businessStatus,
division,
bank,
};
const totalPages = Math.max(1, Math.ceil(totalCount / query.pageSize));
const currentPage = Math.min(query.page, totalPages);
return (
<MerchantList
items={items}
codeTables={codeTables}
query={query}
currentPage={currentPage}
totalPages={totalPages}
totalCount={totalCount}
/>
);
}