통수위험 결과조회 공통 그리드 및 지도 표출 보완

This commit is contained in:
kiminchan
2026-08-20 17:09:33 +09:00
parent 386fdade59
commit 839d31b9ca
9 changed files with 254 additions and 160 deletions
@@ -223,8 +223,8 @@ export const windowPopupDefinitions = {
flowRiskPopup: {
key: "flowRiskPopup",
title: "통수 위험",
width: 1360,
height: 600,
width: 1380,
height: 900,
},
} as const satisfies Record<string, WindowPopupDefinition>;
@@ -64,6 +64,7 @@ export const WINDOW_POPUP_MESSAGE_TYPE = {
WATER_RISK_READY: "sn:popup:waterRiskReady",
WATER_RISK_SYNC: "sn:popup:waterRiskSync",
WATER_RISK_SELECT_RESULT: "sn:popup:waterRiskSelectResult",
WATER_RISK_CLOSED: "sn:popup:waterRiskClosed",
REPAIR_HISTORY_SHOW_RESULTS: "sn:popup:repairHistoryShowResults",
REPAIR_HISTORY_SELECT_PIPE: "sn:popup:repairHistorySelectPipe",
REPAIR_HISTORY_CLEAR: "sn:popup:repairHistoryClear",
@@ -1,19 +1,21 @@
"use client";
import { useMemo, type ReactNode } from "react";
import { type ReactNode, useMemo } from "react";
import {
getCoreRowModel,
useReactTable,
type ColumnDef,
getCoreRowModel,
type PaginationState,
useReactTable,
} from "@tanstack/react-table";
import {
StandardDataTable,
getStandardRowNumber,
type ScrollMode,
StandardDataTable,
type UiHeadProps,
} from "@common/business_components";
import type { UiTableSort } from "@common/business_components/ui/table";
type MapPopupDataTableProps<T extends Record<string, unknown>> = {
rows: T[];
@@ -40,6 +42,8 @@ type MapPopupDataTableProps<T extends Record<string, unknown>> = {
headId: string,
rowIndex: number,
) => ReactNode | undefined;
sort?: UiTableSort;
onSortChange?: (sort: UiTableSort | undefined) => void;
};
const ROW_NUMBER_IDS = new Set(["no", "rowNo", "rowNumber"]);
@@ -72,6 +76,8 @@ export default function MapPopupDataTable<T extends Record<string, unknown>>({
onCellClick,
clickableHeadIds,
renderCell,
sort,
onSortChange,
}: MapPopupDataTableProps<T>) {
const visibleHeads = useMemo(
() =>
@@ -85,7 +91,33 @@ export default function MapPopupDataTable<T extends Record<string, unknown>>({
visibleHeads.map((head) => ({
id: head.id,
accessorFn: (row) => row[head.id],
header: ROW_NUMBER_IDS.has(head.id) ? "순번" : head.title,
header: () => {
const title = ROW_NUMBER_IDS.has(head.id) ? "순번" : head.title;
if (!head.sortable || !onSortChange) return title;
const key = head.sortKey ?? head.id;
const direction = sort?.key === key ? sort.direction : undefined;
return (
<button
type="button"
className="inline-flex w-full items-center justify-center gap-1.5"
aria-label={`${title} 정렬`}
onClick={() => {
if (direction === undefined) {
onSortChange({ key, direction: "asc" });
} else if (direction === "asc") {
onSortChange({ key, direction: "desc" });
} else {
onSortChange(undefined);
}
}}
>
<span>{title}</span>
<span className="text-[8px] leading-none" aria-hidden="true">
{direction === "asc" ? "▲" : direction === "desc" ? "▼" : "↕"}
</span>
</button>
);
},
cell: ({ row, getValue }) => {
const rowIndex = row.index;
const rendered = renderCell?.(row.original, head.id, rowIndex);
@@ -132,8 +164,10 @@ export default function MapPopupDataTable<T extends Record<string, unknown>>({
page,
pageSize,
renderCell,
sort,
total,
visibleHeads,
onSortChange,
],
);
const pagination: PaginationState = {