260515_01_ENH: 클라이언트 수정사항 반영 및 다른 조사들 data 연결
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import { useLayoutFilter } from "@/components/layout/LayoutCategoryContext";
|
||||
import CustomerSatisfactionTotal from "@/components/kfpa/CustomerSatisfactionTotal";
|
||||
import CustomerSatisfactionDetail from "@/components/kfpa/CustomerSatisfactionDetail";
|
||||
|
||||
const BridgePlatformPage = () => {
|
||||
return (
|
||||
<div>BridgePlatformPage</div>
|
||||
)
|
||||
}
|
||||
const { selectedDiv } = useLayoutFilter();
|
||||
|
||||
export default BridgePlatformPage;
|
||||
return selectedDiv === "-1" ? <CustomerSatisfactionTotal /> : <CustomerSatisfactionDetail selectedDiv={selectedDiv} />;
|
||||
};
|
||||
|
||||
export default BridgePlatformPage;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import { useLayoutFilter } from "@/components/layout/LayoutCategoryContext";
|
||||
import CustomerSatisfactionTotal from "@/components/kfpa/CustomerSatisfactionTotal";
|
||||
import CustomerSatisfactionDetail from "@/components/kfpa/CustomerSatisfactionDetail";
|
||||
|
||||
const ConsultingPage = () => {
|
||||
return (
|
||||
<div>ConsultingPage</div>
|
||||
)
|
||||
}
|
||||
const { selectedDiv } = useLayoutFilter();
|
||||
|
||||
export default ConsultingPage;
|
||||
return selectedDiv === "-1" ? <CustomerSatisfactionTotal /> : <CustomerSatisfactionDetail selectedDiv={selectedDiv} />;
|
||||
};
|
||||
|
||||
export default ConsultingPage;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
"use client";
|
||||
|
||||
'use client'
|
||||
import { useLayoutFilter } from "@/components/layout/LayoutCategoryContext";
|
||||
import CustomerSatisfactionTotal from "@/components/kfpa/CustomerSatisfactionTotal";
|
||||
import CustomerSatisfactionDetail from "@/components/kfpa/CustomerSatisfactionDetail";
|
||||
|
||||
const FireInvestigationPage = () => {
|
||||
return (
|
||||
<div>FireInvestigationPage</div>
|
||||
)
|
||||
}
|
||||
const { selectedDiv } = useLayoutFilter();
|
||||
|
||||
export default FireInvestigationPage;
|
||||
return selectedDiv === "-1" ? <CustomerSatisfactionTotal /> : <CustomerSatisfactionDetail selectedDiv={selectedDiv} />;
|
||||
};
|
||||
|
||||
export default FireInvestigationPage;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
const InsuranceOperationPage = () => {
|
||||
return (
|
||||
<div>InsuranceOperationPage</div>
|
||||
)
|
||||
}
|
||||
import { useLayoutFilter } from "@/components/layout/LayoutCategoryContext";
|
||||
import CustomerSatisfactionTotal from "@/components/kfpa/CustomerSatisfactionTotal";
|
||||
import CustomerSatisfactionDetail from "@/components/kfpa/CustomerSatisfactionDetail";
|
||||
|
||||
export default InsuranceOperationPage;
|
||||
const InsuranceOperationsPage = () => {
|
||||
const { selectedDiv } = useLayoutFilter();
|
||||
|
||||
return selectedDiv === "-1" ? <CustomerSatisfactionTotal /> : <CustomerSatisfactionDetail selectedDiv={selectedDiv} />;
|
||||
};
|
||||
|
||||
export default InsuranceOperationsPage;
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
import {redirect} from "next/navigation";
|
||||
import { ADMIN_QUERY_PARAM, ADMIN_ROUTE_KEY } from "@/lib/admin-route";
|
||||
"use client"
|
||||
|
||||
type MainPageProps = {
|
||||
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
||||
};
|
||||
import CustomerSatisfactionSummary from "@/components/kfpa/CustomerSatisfactionSummary";
|
||||
|
||||
const MainPage = async ({ searchParams }: MainPageProps) => {
|
||||
const params = await searchParams;
|
||||
const adminKey = params?.[ADMIN_QUERY_PARAM];
|
||||
const adminKeyValue = Array.isArray(adminKey) ? adminKey[0] : adminKey;
|
||||
const query = adminKeyValue === ADMIN_ROUTE_KEY ? `?${ADMIN_QUERY_PARAM}=${ADMIN_ROUTE_KEY}` : "";
|
||||
|
||||
redirect(`/safety-inspection${query}`);
|
||||
const MainPage = () => {
|
||||
return <CustomerSatisfactionSummary />
|
||||
}
|
||||
|
||||
export default MainPage;
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import {useLayoutFilter} from "@/components/layout/LayoutCategoryContext";
|
||||
import SafetyInspectionTotal from "./sub/SafetyInspectionTotal";
|
||||
import SafetyInspectionDivDetail from "./sub/SafetyInspectionDivDetail";
|
||||
import { useLayoutFilter } from "@/components/layout/LayoutCategoryContext";
|
||||
import CustomerSatisfactionTotal from "@/components/kfpa/CustomerSatisfactionTotal";
|
||||
import CustomerSatisfactionDetail from "@/components/kfpa/CustomerSatisfactionDetail";
|
||||
|
||||
const SafetyInspectionPage = () => {
|
||||
const { selectedDiv } = useLayoutFilter();
|
||||
|
||||
return (
|
||||
selectedDiv === "-1" ? <SafetyInspectionTotal /> : <SafetyInspectionDivDetail selectedDiv={selectedDiv} />
|
||||
)
|
||||
}
|
||||
return selectedDiv === "-1" ? <CustomerSatisfactionTotal /> : <CustomerSatisfactionDetail selectedDiv={selectedDiv} />;
|
||||
};
|
||||
|
||||
export default SafetyInspectionPage;
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import DataTable from "@/components/table/DataTable";
|
||||
import type { DataColumn } from "@/components/table/types";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DIV_KEY_MAP } from "@/config/kfpaConfig";
|
||||
import { formatKoreanBaseDate } from "@/lib/utils";
|
||||
import { useWriteDivCommentMutation } from "@/query/admin";
|
||||
import { statisticsQueryKeys } from "@/query/key/keys";
|
||||
import { useDivDetailDataQuery } from "@/query/statistics";
|
||||
import type { CommentValue, DivDetailData } from "@/types/kfpa";
|
||||
import { Pencil, Save, X } from 'lucide-react';
|
||||
import SectionTitle from "@/components/common/SectionTitle";
|
||||
import { hasAdminRouteParam } from "@/lib/admin-route";
|
||||
|
||||
export type SafetyInspectionDivDetailProps = {
|
||||
selectedDiv: string;
|
||||
};
|
||||
|
||||
type RankRow = {
|
||||
type: string;
|
||||
csi: number | null;
|
||||
rank: string;
|
||||
};
|
||||
|
||||
type CommentField = keyof CommentValue;
|
||||
|
||||
type CommentRow = {
|
||||
label: string;
|
||||
importance: string;
|
||||
field: CommentField;
|
||||
};
|
||||
|
||||
type CommentTableRow = CommentRow & Record<string, unknown>;
|
||||
|
||||
const DEFAULT_COMMENT_COLUMNS = [
|
||||
{ key: "performance25", label: "25년 성과" },
|
||||
{ key: "plan26", label: "26년 업무계획" },
|
||||
{ key: "performance26", label: "26년 업무계획 진행률 및 성과" },
|
||||
];
|
||||
|
||||
const COMMENT_ROWS: CommentRow[] = [
|
||||
{ label: "고객 직접 체감", importance: "★★★", field: "directExperience" },
|
||||
{ label: "고객 간접 체감", importance: "★★", field: "indirectExperience" },
|
||||
{ label: "내부역량 강화 등", importance: "★", field: "capability" },
|
||||
];
|
||||
|
||||
const RANK_ROWS = [
|
||||
{ key: "90", label: "일반" },
|
||||
{ key: "4", label: "공장" },
|
||||
{ key: "12", label: "아파트" },
|
||||
];
|
||||
|
||||
const getSelectedDetail = (data: Record<string, DivDetailData> | undefined, selectedDiv: string) => {
|
||||
if (!data) return undefined;
|
||||
return data[selectedDiv] ?? Object.values(data)[0];
|
||||
};
|
||||
|
||||
const getCommentColumns = (commentValues?: Record<string, CommentValue>) => {
|
||||
const keys = Object.keys(commentValues ?? {});
|
||||
const selectedKeys = keys.length > 0 ? keys : DEFAULT_COMMENT_COLUMNS.map((column) => column.key);
|
||||
|
||||
return selectedKeys.map((key, index) => ({
|
||||
key,
|
||||
label: DEFAULT_COMMENT_COLUMNS[index]?.label ?? key,
|
||||
}));
|
||||
};
|
||||
|
||||
const createEmptyCommentValue = (): CommentValue => ({
|
||||
directExperience: "",
|
||||
indirectExperience: "",
|
||||
capability: "",
|
||||
});
|
||||
|
||||
const createDraft = (columns: Array<{ key: string }>, source?: Record<string, CommentValue>) =>
|
||||
columns.reduce<Record<string, CommentValue>>((acc, column) => {
|
||||
acc[column.key] = {
|
||||
...createEmptyCommentValue(),
|
||||
...(source?.[column.key] ?? {}),
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const SafetyInspectionDivDetail = ({ selectedDiv }: SafetyInspectionDivDetailProps) => {
|
||||
const searchParams = useSearchParams();
|
||||
const queryClient = useQueryClient();
|
||||
const { data, isLoading, isError } = useDivDetailDataQuery(selectedDiv, selectedDiv !== "-1");
|
||||
const writeMutation = useWriteDivCommentMutation();
|
||||
|
||||
const detail = useMemo(() => getSelectedDetail(data, selectedDiv), [data, selectedDiv]);
|
||||
const commentColumns = useMemo(() => getCommentColumns(detail?.commentValues), [detail?.commentValues]);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [draft, setDraft] = useState<Record<string, CommentValue>>(() =>
|
||||
createDraft(commentColumns, detail?.commentValues)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setIsEditing(false);
|
||||
setDraft(createDraft(commentColumns, detail?.commentValues));
|
||||
}, [commentColumns, detail?.commentValues, selectedDiv]);
|
||||
|
||||
const baseDateLabel = useMemo(() => formatKoreanBaseDate(), []);
|
||||
const isAuthenticated = hasAdminRouteParam(searchParams);
|
||||
|
||||
const rankRows: RankRow[] = useMemo(() => {
|
||||
const ranks = detail?.csiRanks ?? {};
|
||||
return RANK_ROWS.map(({ key, label }) => ({
|
||||
type: label,
|
||||
csi: ranks[key]?.csi ?? 0,
|
||||
rank: `${ranks[key]?.divRank ?? 0}/6`,
|
||||
}));
|
||||
}, [detail?.csiRanks]);
|
||||
|
||||
const rankColumns: DataColumn<RankRow>[] = useMemo(
|
||||
() => [
|
||||
{ key: "type", header: "물건 유형", align: "center" },
|
||||
{
|
||||
key: "csi",
|
||||
header: "고객만족지수",
|
||||
align: "center",
|
||||
render: (row) => (typeof row.csi === "number" ? row.csi.toFixed(2) : "-"),
|
||||
},
|
||||
{ key: "rank", header: "지역본부순위", align: "center" },
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
const updateDraft = (columnKey: string, field: CommentField, value: string) => {
|
||||
setDraft((prev) => ({
|
||||
...prev,
|
||||
[columnKey]: {
|
||||
...createEmptyCommentValue(),
|
||||
...(prev[columnKey] ?? {}),
|
||||
[field]: value,
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
const commentRows: CommentTableRow[] = useMemo(
|
||||
() =>
|
||||
COMMENT_ROWS.map((row) => ({
|
||||
...row,
|
||||
...Object.fromEntries(commentColumns.map((column) => [column.key, draft[column.key]?.[row.field] ?? ""])),
|
||||
})),
|
||||
[commentColumns, draft]
|
||||
);
|
||||
|
||||
const commentTableColumns: DataColumn<CommentTableRow>[] = useMemo(
|
||||
() => [
|
||||
{
|
||||
key: "label",
|
||||
header: "",
|
||||
rowHead: true,
|
||||
width: 170,
|
||||
align: "center",
|
||||
cellClassName: "bg-red-50 text-center font-bold",
|
||||
},
|
||||
{
|
||||
key: "importance",
|
||||
header: "중요도(난이도)",
|
||||
width: 110,
|
||||
align: "center",
|
||||
cellClassName: "font-bold",
|
||||
},
|
||||
...commentColumns.map<DataColumn<CommentTableRow>>((column) => ({
|
||||
key: column.key,
|
||||
header: column.label,
|
||||
align: "left",
|
||||
cellClassName: "align-top",
|
||||
render: (row) => {
|
||||
const value = String(draft[column.key]?.[row.field] ?? "");
|
||||
|
||||
if (!isEditing) {
|
||||
return <div className="min-h-24 whitespace-pre-wrap text-left">{value || "-"}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<textarea
|
||||
className="min-h-28 w-full resize-y border border-gray-300 bg-background p-2 text-sm outline-none focus:border-primary"
|
||||
value={value}
|
||||
onChange={(event) => updateDraft(column.key, row.field, event.target.value)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
})),
|
||||
],
|
||||
[commentColumns, draft, isEditing]
|
||||
);
|
||||
|
||||
const handleSave = () => {
|
||||
writeMutation.mutate(
|
||||
{
|
||||
divId: Number(selectedDiv),
|
||||
commentValues: draft,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
setIsEditing(false);
|
||||
queryClient.invalidateQueries({ queryKey: statisticsQueryKeys.divDetail(selectedDiv) });
|
||||
toast.success("저장되었습니다.");
|
||||
},
|
||||
onError: () => {
|
||||
toast.error("저장하지 못했습니다.");
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleEditToggle = () => {
|
||||
if (!isAuthenticated) return;
|
||||
if (isEditing) {
|
||||
handleSave();
|
||||
return;
|
||||
}
|
||||
setIsEditing(true);
|
||||
};
|
||||
|
||||
const handleCancelEdit = () => {
|
||||
setDraft(createDraft(commentColumns, detail?.commentValues));
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return <div className="content-text-sm text-muted-foreground">데이터를 불러오는 중입니다.</div>;
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return <div className="content-text-sm text-destructive">지역본부 상세 데이터를 불러오지 못했습니다.</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-8">
|
||||
<div>
|
||||
<SectionTitle title={DIV_KEY_MAP[selectedDiv] ?? ""} />
|
||||
|
||||
<div className="mt-6 mb-2 max-w-[360px]">
|
||||
<div className="mb-2 text-right content-text-base">{baseDateLabel}</div>
|
||||
<DataTable
|
||||
columns={rankColumns}
|
||||
rows={rankRows}
|
||||
tableClassName="kfpa-table"
|
||||
wrapperClassName="w-full"
|
||||
minWidth={360}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{isAuthenticated && (
|
||||
<div className="mb-2 flex justify-end gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
className={
|
||||
isEditing
|
||||
? "gap-2 border border-transparent bg-red-600 text-white w-25 shadow-sm hover:bg-red-500 hover:text-white"
|
||||
: "gap-2 border border-transparent bg-green-600 text-white w-25 shadow-sm hover:bg-green-500 hover:text-white"
|
||||
}
|
||||
disabled={writeMutation.isPending}
|
||||
onClick={handleEditToggle}
|
||||
>
|
||||
{isEditing ? (
|
||||
<>
|
||||
<Save className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"저장"}</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Pencil className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"수정"}</span>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
{isEditing && (
|
||||
<Button
|
||||
type="button"
|
||||
className="gap-2 border border-transparent bg-black-400 text-white w-25 shadow-sm hover:bg-black-200 hover:text-white"
|
||||
disabled={writeMutation.isPending}
|
||||
onClick={handleCancelEdit}
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"취소"}</span>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<DataTable
|
||||
columns={commentTableColumns}
|
||||
rows={commentRows}
|
||||
tableClassName="kfpa-table"
|
||||
subheadRowClassName="bg-red-50"
|
||||
wrapperClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SafetyInspectionDivDetail;
|
||||
@@ -1,268 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { type ReactNode, useMemo } from "react";
|
||||
import type { ChartData } from "@/components/chart/types";
|
||||
import TopChartTable from "@/components/combo/TopChartTable";
|
||||
import type { TopChartTableRow } from "@/components/combo/types";
|
||||
import {cn, formatKoreanBaseDate} from "@/lib/utils";
|
||||
import { useCsiDataQuery } from "@/query/statistics";
|
||||
import type { CsiData, CsiDataMap } from "@/types/kfpa";
|
||||
import VerticalBar from "@/components/chart/VerticalBar";
|
||||
import {SignStyle} from "@/components/table/types";
|
||||
import {GAP_WORDING} from "@/const/kfpa.const";
|
||||
import {DIV_KEYS, REGION_KEY_MAP} from "@/config/kfpaConfig";
|
||||
|
||||
export const signStyleGapRow: SignStyle<TopChartTableRow> = {
|
||||
rowSelector: (row) => row.label === GAP_WORDING,
|
||||
display: "arrow",
|
||||
arrowWithNumber: true,
|
||||
paint: "text",
|
||||
};
|
||||
|
||||
const DIV_COLUMNS = DIV_KEYS.map((key) => ({
|
||||
key,
|
||||
label: key === "-1" ? "전체" : REGION_KEY_MAP[key],
|
||||
}));
|
||||
|
||||
const METRICS: Array<{
|
||||
key: keyof Omit<CsiData, "wave">;
|
||||
label: ReactNode;
|
||||
group?: "direct" | "indirect";
|
||||
}> = [
|
||||
{ key: "csi", label: "고객만족지수(CSI)" },
|
||||
{
|
||||
key: "safeHelp",
|
||||
label: (
|
||||
<>
|
||||
① 현장 안전점검이
|
||||
<br />
|
||||
도움되는 정도
|
||||
</>
|
||||
),
|
||||
group: "direct",
|
||||
},
|
||||
{
|
||||
key: "recHelp",
|
||||
label: (
|
||||
<>
|
||||
② 위험 개선 권고사항이
|
||||
<br />
|
||||
도움되는 정도
|
||||
</>
|
||||
),
|
||||
group: "direct",
|
||||
},
|
||||
{ key: "staffProf", label: "③ 점검직원 전문성", group: "indirect" },
|
||||
{ key: "staffAtt", label: "④ 점검직원 태도", group: "indirect" },
|
||||
];
|
||||
|
||||
const getWaveLabel = (wave: number) => {
|
||||
const text = String(wave);
|
||||
return `${wave >= 100 ? text.slice(-2) : text}년`;
|
||||
};
|
||||
|
||||
const getDataByWave = (dataMap: CsiDataMap | undefined, divKey: string, wave: number) =>
|
||||
dataMap?.[divKey]?.find((item) => item.wave === wave);
|
||||
|
||||
const getMetricValue = (
|
||||
dataMap: CsiDataMap | undefined,
|
||||
divKey: string,
|
||||
wave: number,
|
||||
metricKey: keyof Omit<CsiData, "wave">
|
||||
) => getDataByWave(dataMap, divKey, wave)?.[metricKey] ?? null;
|
||||
|
||||
const getGapValue = (
|
||||
dataMap: CsiDataMap | undefined,
|
||||
divKey: string,
|
||||
previousWave: number,
|
||||
currentWave: number,
|
||||
metricKey: keyof Omit<CsiData, "wave">
|
||||
) => {
|
||||
const previousValue = getMetricValue(dataMap, divKey, previousWave, metricKey);
|
||||
const currentValue = getMetricValue(dataMap, divKey, currentWave, metricKey);
|
||||
|
||||
if (previousValue == null || currentValue == null) return null;
|
||||
return currentValue - previousValue;
|
||||
};
|
||||
|
||||
const getPreAppendCells = (
|
||||
metric: (typeof METRICS)[number],
|
||||
metricIndex: number,
|
||||
waveIndex: number,
|
||||
rowCountPerMetric: number
|
||||
): TopChartTableRow["preAppendCells"] => {
|
||||
if (waveIndex !== 0) return undefined;
|
||||
|
||||
if (metric.key === "csi") {
|
||||
return [
|
||||
{
|
||||
content: "고객만족지수(CSI)",
|
||||
colSpan: 2,
|
||||
rowSpan: rowCountPerMetric,
|
||||
width: 240,
|
||||
className: "bg-red-100 text-center align-middle font-bold content-text-base",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const cells: TopChartTableRow["preAppendCells"] = [];
|
||||
|
||||
if (metric.group === "direct" && metricIndex === 1) {
|
||||
cells.push({
|
||||
content: "직접 요소",
|
||||
rowSpan: rowCountPerMetric * 2,
|
||||
width: 60,
|
||||
className: "bg-red-50 text-center align-middle font-bold content-text-base",
|
||||
});
|
||||
}
|
||||
|
||||
if (metric.group === "indirect" && metricIndex === 3) {
|
||||
cells.push({
|
||||
content: "간접 요소",
|
||||
rowSpan: rowCountPerMetric * 2,
|
||||
width: 60,
|
||||
className: "bg-green-200 text-center align-middle font-bold content-text-base",
|
||||
});
|
||||
}
|
||||
|
||||
cells.push({
|
||||
content: metric.label,
|
||||
rowSpan: rowCountPerMetric,
|
||||
width: 170,
|
||||
className:
|
||||
metric.group === "indirect"
|
||||
? "bg-green-200 text-left align-middle font-bold content-text-base"
|
||||
: "bg-red-50 text-left align-middle font-bold content-text-base",
|
||||
});
|
||||
|
||||
return cells;
|
||||
};
|
||||
|
||||
const SafetyInspectionTotal = () => {
|
||||
const { data, isLoading, isError } = useCsiDataQuery();
|
||||
const baseDateLabel = useMemo(() => formatKoreanBaseDate(), []);
|
||||
|
||||
const { categories, rows, verticalChartData } = useMemo(() => {
|
||||
const waves = Array.from(
|
||||
new Set(
|
||||
Object.values(data ?? {})
|
||||
.flat()
|
||||
.map((item) => item.wave)
|
||||
.filter((wave) => Number.isFinite(wave))
|
||||
)
|
||||
).sort((a, b) => a - b);
|
||||
|
||||
const latestWave = waves.at(-1);
|
||||
const selectedWaves = latestWave == null ? [] : [latestWave - 1, latestWave];
|
||||
const categories = DIV_COLUMNS.map((div) => div.label);
|
||||
|
||||
const rows: TopChartTableRow[] =
|
||||
selectedWaves.length === 0
|
||||
? []
|
||||
: METRICS.flatMap((metric, metricIndex) =>
|
||||
[
|
||||
{
|
||||
label: GAP_WORDING,
|
||||
values: DIV_COLUMNS.map((div) =>
|
||||
getGapValue(data, div.key, selectedWaves[0], selectedWaves[1], metric.key)
|
||||
),
|
||||
},
|
||||
...selectedWaves.map((wave) => ({
|
||||
label: getWaveLabel(wave),
|
||||
values: DIV_COLUMNS.map((div) => getMetricValue(data, div.key, wave, metric.key)),
|
||||
})),
|
||||
].map((row, rowIndex) => {
|
||||
let labelColorClassName: string | undefined;
|
||||
|
||||
if (metric.key === "csi") {
|
||||
labelColorClassName = "bg-red-100";
|
||||
} else if (metric.group === "indirect") {
|
||||
labelColorClassName = "bg-green-200";
|
||||
} else if (metric.group === "direct") {
|
||||
labelColorClassName = "bg-red-50";
|
||||
}
|
||||
|
||||
return {
|
||||
...row,
|
||||
preAppendCells: getPreAppendCells(metric, metricIndex, rowIndex, selectedWaves.length + 1),
|
||||
labelClassName: cn(
|
||||
labelColorClassName,
|
||||
"text-center",
|
||||
row.label !== GAP_WORDING && "font-bold"
|
||||
),
|
||||
labelWidth: 90,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
const verticalChartData: ChartData = {
|
||||
categories,
|
||||
series: selectedWaves.map((wave) => ({
|
||||
name: getWaveLabel(wave),
|
||||
data: DIV_COLUMNS.map((div) => getDataByWave(data, div.key, wave)?.csi ?? null),
|
||||
})),
|
||||
};
|
||||
|
||||
return {
|
||||
categories,
|
||||
rows,
|
||||
verticalChartData,
|
||||
};
|
||||
}, [data]);
|
||||
|
||||
if (isLoading) {
|
||||
return <div className="content-text-sm text-muted-foreground">데이터를 불러오는 중입니다.</div>;
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return <div className="content-text-sm text-destructive">고객만족도 데이터를 불러오지 못했습니다.</div>;
|
||||
}
|
||||
|
||||
if (rows.length === 0) {
|
||||
return <div className="content-text-sm text-muted-foreground">표시할 고객만족도 데이터가 없습니다.</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<TopChartTable
|
||||
title="안전점검 특관관계자 만족도조사"
|
||||
categories={categories}
|
||||
rows={rows}
|
||||
subLabelHeader={baseDateLabel}
|
||||
signStyle={signStyleGapRow}
|
||||
minWidth={1120}
|
||||
chartHeight={260}
|
||||
chart={
|
||||
<VerticalBar
|
||||
data={verticalChartData}
|
||||
height="100%"
|
||||
paletteVarNames={["--chart-5", "--chart-7"]}
|
||||
valueFormatter={(value) => value.toFixed(2)}
|
||||
barMaxWidth={30}
|
||||
showFocusLabel="all"
|
||||
labelOptions={{ position: "top", distance: 4 }}
|
||||
grid={{ left: 0, right: 0, top: 40, bottom: 5 }}
|
||||
xAxis={{
|
||||
type: "category",
|
||||
data: categories,
|
||||
axisLabel: { show: false },
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
}}
|
||||
yAxis={{
|
||||
type: "value",
|
||||
min: 0,
|
||||
max: 5,
|
||||
axisLabel: { show: false },
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
splitLine: { show: false },
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SafetyInspectionTotal;
|
||||
@@ -1,9 +1,13 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
const BridgePage = () => {
|
||||
return (
|
||||
<div>test</div>
|
||||
)
|
||||
}
|
||||
import { useLayoutFilter } from "@/components/layout/LayoutCategoryContext";
|
||||
import CustomerSatisfactionTotal from "@/components/kfpa/CustomerSatisfactionTotal";
|
||||
import CustomerSatisfactionDetail from "@/components/kfpa/CustomerSatisfactionDetail";
|
||||
|
||||
export default BridgePage;
|
||||
const UcisPage = () => {
|
||||
const { selectedDiv } = useLayoutFilter();
|
||||
|
||||
return selectedDiv === "-1" ? <CustomerSatisfactionTotal /> : <CustomerSatisfactionDetail selectedDiv={selectedDiv} />;
|
||||
};
|
||||
|
||||
export default UcisPage;
|
||||
|
||||
Reference in New Issue
Block a user