diff --git a/apps/sn/app/(map-layout)/map/components/agedPipeStatusByCtpv/AgedPipeStatusByCtpvPopupPage.tsx b/apps/sn/app/(map-layout)/map/components/agedPipeStatusByCtpv/AgedPipeStatusByCtpvPopupPage.tsx index 293ae3fe3..05dd3447c 100644 --- a/apps/sn/app/(map-layout)/map/components/agedPipeStatusByCtpv/AgedPipeStatusByCtpvPopupPage.tsx +++ b/apps/sn/app/(map-layout)/map/components/agedPipeStatusByCtpv/AgedPipeStatusByCtpvPopupPage.tsx @@ -2,14 +2,23 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import { Button, Input } from "@common/components"; -import { StandardPopupLayout } from "@common/business_components"; +import { + StandardDataTable, + StandardPopupLayout, +} from "@common/business_components"; +import { + getCoreRowModel, + getPaginationRowModel, + useReactTable, + type ColumnDef, + type PaginationState, +} from "@tanstack/react-table"; import { getRawJson } from "@/components/lib/api"; import LoadingOverlay from "@/components/ui/LoadingBar"; import { useAlertStore } from "@/shared/lib"; import { windowPopupDefinitions } from "@/features/windowPopup/model/popupDefinitions"; import { AGED_PIPE_STATUS_BY_CTPV_DEFAULT_ELAPSED_YEARS, - buildAgedPipeStatusByCtpvHeadList, buildAgedPipeStatusYearOptions, getAgedPipeStatusByCtpvValidationMessage, normalizeAgedPipeStatusByCtpvResponse, @@ -20,7 +29,6 @@ import { type AgedPipeStatusByCtpvRow, } from "./agedPipeStatusByCtpvUtils"; import { downloadAgedPipeStatusByCtpvExcel } from "./agedPipeStatusByCtpvExport"; -import MapPopupDataTable from "@/features/windowPopup/ui/MapPopupDataTable"; import PopupSearchPanel from "@/features/windowPopup/ui/PopupSearchPanel"; // CS 목록과 동일하게 한 페이지에는 최대 10개 시도만 표시한다. @@ -52,21 +60,48 @@ export default function AgedPipeStatusByCtpvPopupPage() { const [currentPage, setCurrentPage] = useState(1); const yearOptions = useMemo(() => buildAgedPipeStatusYearOptions(), []); - const headList = useMemo( + const columns = useMemo[]>( () => [ - { id: "rowNumber", title: "순번", widthPercent: 7 }, - ...buildAgedPipeStatusByCtpvHeadList(years), + { accessorKey: "rowNumber", header: "순번" }, + { accessorKey: "ctpvNm", header: "시도" }, + ...years.map((year) => ({ + id: `year_${year}`, + header: `${year}년`, + columns: [ + { + accessorKey: `year${year}TotalLengthKm`, + header: "전체관로연장(km)", + }, + { + accessorKey: `year${year}AgedLengthKm`, + header: "노후관로연장(km)", + }, + { + accessorKey: `year${year}AgedRate`, + header: "노후화율(%)", + }, + ], + })), ], [years], ); - const pageRows = useMemo( - () => - rows.slice( - (currentPage - 1) * AGED_PIPE_STATUS_PAGE_SIZE, - currentPage * AGED_PIPE_STATUS_PAGE_SIZE, - ), - [currentPage, rows], - ); + + const pagination: PaginationState = { + pageIndex: currentPage - 1, + pageSize: AGED_PIPE_STATUS_PAGE_SIZE, + }; + const table = useReactTable({ + data: rows, + columns, + state: { pagination }, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + onPaginationChange: (updater) => { + const next = + typeof updater === "function" ? updater(pagination) : updater; + setCurrentPage(next.pageIndex + 1); + }, + }); const loadRows = useCallback( async (nextFilters: AgedPipeStatusByCtpvFilters) => { @@ -249,18 +284,12 @@ export default function AgedPipeStatusByCtpvPopupPage() { - > - } - headlist={headList} + 2 ? "horizontal" : "none"} - minTableWidth={years.length > 2 ? "120rem" : "100%"} + scrollMode="horizontal" + minTableWidth={years.length > 0 ? "120rem" : "100%"} actions={