"use client"; import { useMemo } from "react"; import DataTable from "@/components/table/DataTable"; import type { DataColumn } from "@/components/table/types"; import { cn } from "@/lib/utils"; import type { DivDetailData, RankRowConfig } from "@/types/kfpa"; type RankRow = { type: string; csi: number | null; rank: string; headerClassName?: string; }; type CustomerSatisfactionRankTableProps = { detail?: DivDetailData; rankRows: readonly RankRowConfig[]; }; const rankColumns: DataColumn[] = [ { key: "type", header: "물건 유형", align: "center", width: 80 }, { key: "csi", header: "고객만족지수", align: "center", decimalPlaces: 2, width: 100, }, { key: "rank", header: "지역본부순위", align: "center", width: 100 }, ]; const CustomerSatisfactionRankTable = ({ detail, rankRows }: CustomerSatisfactionRankTableProps) => { const rows: RankRow[] = useMemo(() => { const ranks = detail?.csiRanks ?? {}; return rankRows.map(([key, label]) => ({ type: label, csi: ranks[key]?.csi ?? 0, rank: `${ranks[key]?.divRank ?? 0}/6`, headerClassName: cn(key === "-1" ? "bg-csi" : "bg-gray-400", "font-bold"), })); }, [detail?.csiRanks, rankRows]); return ( column.key === "type" ? row.headerClassName : undefined } /> ); }; export default CustomerSatisfactionRankTable;