diff --git a/apps/fo/app/store/common/index.tsx b/apps/fo/app/store/common/index.tsx index d88c621e8..bff960099 100644 --- a/apps/fo/app/store/common/index.tsx +++ b/apps/fo/app/store/common/index.tsx @@ -214,6 +214,17 @@ export const roundUp = (value: number, precision: number = 1): number => { return Math.round(value * (10 ** precision)) / (10 ** precision); } +/** + * 수질 데이터 포맷 변경 함수 + * @param value : 수질 데이터 + * @param day : 일수 + * @param digit : 소수점 자리수 + */ +export const qltyDataSetting = (value: number, day : number, digit: number) => { + const toZero = digit === 1 ? '0.0' : digit === 2 ? '0.00' : '0.000'; + return value > 0 ? roundUp((value/day), digit).toFixed(digit) : toZero; +}; + /** * STORE - API */ diff --git a/apps/fo/app/store/dashboard/index.tsx b/apps/fo/app/store/dashboard/index.tsx index 2b79adfc7..d772d72b3 100644 --- a/apps/fo/app/store/dashboard/index.tsx +++ b/apps/fo/app/store/dashboard/index.tsx @@ -5,7 +5,7 @@ import { getFetch } from "@/app/components/api"; import CalcRainEffect from "@/app/components/common/CalcRainEffect"; import DataForm from "@/app/components/common/DataForm"; -import { fetchPlanInfo, OSU_PERCENT, roundUp } from "../common"; +import { fetchPlanInfo, OSU_PERCENT, qltyDataSetting, roundUp } from "../common"; import type { FacilityWaterQltyProps } from "../facilityWaterQlty"; import { fetchFlowRateModalList } from "../flowRate"; @@ -735,11 +735,6 @@ const fetchMainGraph = async (searchYear: string|undefined, fcltyCd: string|unde // 수질 데이터 청천시, 강우시 재계산 const calcWaterQltyData = async (data: any[], searchYear : string|undefined, fcltyCd : string|undefined) => { - // 데이터 결과값 dataFormat 가공 - const qltyDataSetting = (value: number, day : number, digit: number) => { - const toZero = digit === 1 ? '0.0' : digit === 2 ? '0.00' : '0.000'; - return value > 0 ? roundUp((value/day), digit).toFixed(digit) : toZero; - }; const orgData = data; const res = await fetchMainGraph(searchYear, fcltyCd);