63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
"use client"
|
|
import { useFoStore } from "@/app/store";
|
|
import { UiTable } from "@common/business_components/ui/table";
|
|
import { useEffect, useState } from "react";
|
|
|
|
export type facilityInfoProps = {
|
|
searchYear?: string;
|
|
fcltyList?: { bscFctCd: string, bscFctNm: string, fcltyCpc: number | '', trtFrfNm: string, efflWqltStndrdNm: string }[];
|
|
};
|
|
|
|
export default function RainManageTab({searchYear = '', fcltyList = []}: facilityInfoProps) {
|
|
|
|
const {
|
|
Common,
|
|
searchRainManage,
|
|
RainManage
|
|
} = useFoStore((state) => state);
|
|
|
|
const [hasSearched, setHasSearched] = useState(false);
|
|
// 이전 시설코드 저장
|
|
const [prevFacilityCode, setPrevFacilityCode] = useState<string>('');
|
|
|
|
const {
|
|
isInit,
|
|
} = Common;
|
|
|
|
const {
|
|
upHeadListRainManage,
|
|
rainManageList,
|
|
} = RainManage;
|
|
|
|
const tableData = fcltyList;
|
|
|
|
useEffect(() => {
|
|
if (!isInit && tableData[0]?.bscFctCd && (tableData[0].bscFctCd !== prevFacilityCode || !hasSearched)) {
|
|
searchRainManage(searchYear, tableData[0].bscFctCd, false);
|
|
setHasSearched(true);
|
|
setPrevFacilityCode(tableData[0].bscFctCd);
|
|
}
|
|
}, [fcltyList, isInit, searchRainManage, searchYear, tableData, hasSearched, prevFacilityCode]);
|
|
|
|
// 연도가 바뀌면 hasSearched를 false로 리셋
|
|
useEffect(() => {
|
|
setHasSearched(false);
|
|
}, [searchYear]);
|
|
|
|
return (
|
|
<div>
|
|
<UiTable
|
|
headName=""
|
|
tableData={rainManageList}
|
|
headlist={upHeadListRainManage}
|
|
pageSize={0}
|
|
total={0}
|
|
cellClick={undefined}
|
|
onPageChange={() => {}}
|
|
>
|
|
</UiTable>
|
|
<span className="text-2xl font-bold text-gray-500">☞ 일수에 강우영향일 포함됨</span>
|
|
</div>
|
|
)
|
|
}
|