import { useState } from "react"; import DataGrid from "@/components/module/DataGrid"; import SearchForm from "@/components/module/SearchForm"; import type { ColumnConfig } from "@/components/type/DataGrid.type"; import type { SearchFormValues } from "@/components/type/SearchForm.type"; import { toGridRows } from "@/components/util/grid/gridFunction"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; import { useAlertStore } from "@/shared/lib"; import { LoadingWithAnimation } from "@common/components"; const StatisticsReviewHistory = () => { const { setMessage: alert } = useAlertStore((state) => state); const [rowData, setRowData] = useState[]>([]); const [isLoading, setIsLoading] = useState(false); const columns: ColumnConfig[] = [ { name: "statsYr", fieldName: "statsYr", header: { text: "연도" }, editable: false }, { name: "ctpvNm", fieldName: "ctpvNm", header: { text: "시도" }, editable: false }, { name: "sggNm", fieldName: "sggNm", header: { text: "시군구" }, editable: false }, { name: "sewerBzmnCd", fieldName: "sewerBzmnCd", header: { text: "하수사업자코드" }, editable: false }, { name: "statsCd", fieldName: "statsCd", header: { text: "통계코드" }, editable: false }, { name: "menuNm", fieldName: "menuNm", header: { text: "통계항목" }, editable: false }, { name: "chckerOpinionSm", fieldName: "chckerOpinionSm", header: { text: "검토자의견" }, editable: false }, { name: "wrterOpinionSm", fieldName: "wrterOpinionSm", header: { text: "처리내역" }, editable: false }, ]; const columnLayout = [ "statsYr", "ctpvNm", "sggNm", "sewerBzmnCd", "statsCd", "menuNm", "chckerOpinionSm", "wrterOpinionSm", ]; const handleSearch = async (values: SearchFormValues) => { if (!values.year?.trim()) { alert("년도를 선택해주세요."); return; } try { setIsLoading(true); const res = await statisticsApi.getStatiscicsManagementReviewHistory({ statsYr: values.year.trim(), ...(values.bsnmCd?.trim() ? { sewerBzmnCd: values.bsnmCd.trim() } : {}), ...(values.sido && values.sido !== "ALL" ? { ctpvNm: values.sido } : {}), }); if (res.status === "success" && Array.isArray(res.data)) { setRowData(toGridRows(res.data)); } else { setRowData([]); alert(res.message || "조회된 데이터가 없습니다."); } } catch { setRowData([]); alert("데이터 조회 중 오류가 발생했습니다."); } finally { setIsLoading(false); } }; const handleReset = () => { setRowData([]); }; return (
{isLoading && (
)}
); }; export default StatisticsReviewHistory;