260515_01_ENH: 클라이언트 수정사항 반영 및 다른 조사들 data 연결
This commit is contained in:
61
src/components/kfpa/CustomerSatisfactionRankTable.tsx
Normal file
61
src/components/kfpa/CustomerSatisfactionRankTable.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
"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<RankRow>[] = [
|
||||
{ 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 (
|
||||
<div className="shrink-0 w-[285px]">
|
||||
<DataTable
|
||||
columns={rankColumns}
|
||||
rows={rows}
|
||||
tableClassName="kfpa-table kfpa-detail-table kfpa-detail-rank-table"
|
||||
wrapperClassName="w-full"
|
||||
minWidth={285}
|
||||
getCellClassName={(row, column) =>
|
||||
column.key === "type" ? row.headerClassName : undefined
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomerSatisfactionRankTable;
|
||||
Reference in New Issue
Block a user