입력 밸류데이션의 재이용 시설명 추가

This commit is contained in:
leedj312
2025-06-26 16:18:52 +09:00
parent cd6568f4df
commit a83cb2709c
2 changed files with 17 additions and 15 deletions
@@ -111,43 +111,46 @@ export default function PublicReuseFaciltyInsert() {
const findAllErrors = (
errorObject: any,
path: (string | number)[] = []
): { message: string; path: (string | number)[] }[] => {
): { message: string; path: (string | number)[]; }[] => {
if (!errorObject) return [];
return Object.keys(errorObject).flatMap((key) => {
const value = errorObject[key];
const currentKey = !isNaN(parseInt(key)) ? parseInt(key) : key;
const newPath = [...path, currentKey];
if (value && typeof value === "object") {
if (typeof value.message === "string") {
return [{ message: value.message, path: newPath }];
return [{ message: value.message, path: newPath }]; // 에러 메시지와 경로 반환
}
return findAllErrors(value, newPath);
}
return [];
});
};
const errorList = findAllErrors(errors);
if (errorList.length > 0) {
errorList.forEach((errorInfo) => {
const { message, path } = errorInfo;
let finalMessage = message;
let prefix = "";
const itemsIndex = path.indexOf("items");
const fcBizsIndex = path.indexOf("fcBizs");
if (itemsIndex > -1 && fcBizsIndex > -1 && path.length > fcBizsIndex + 1) {
if (itemsIndex > -1 && path.length > itemsIndex + 1) {
const itemIdx = path[itemsIndex + 1] as number;
const bizIdx = path[fcBizsIndex + 1] as number;
const cycle = form.getValues(`items.${itemIdx}.fcBizs.${bizIdx}.cycl`);
if (cycle) {
finalMessage = `[${cycle}차수] ${message}`;
const facilityName = form.getValues(`items.${itemIdx}.ruseUtztnFcltNm`);
if (facilityName) {
prefix += `[${facilityName}] `;
}
const fcBizsIndex = path.indexOf("fcBizs");
if (fcBizsIndex > -1 && path.length > fcBizsIndex + 1) {
const bizIdx = path[fcBizsIndex + 1] as number;
const cycle = form.getValues(`items.${itemIdx}.fcBizs.${bizIdx}.cycl`);
if (cycle) {
prefix += `[${cycle}차수] `;
}
}
}
toast.error(finalMessage);
toast.error(`${prefix}${message}`);
});
}
};
@@ -77,7 +77,6 @@ export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (
prfmncHasuInit: async (page: string, sggOrCity: string) => {
try {
const prfmncRes = await hasuListFetch(page, sggOrCity);
console.log("prfmncRes", prfmncRes);
return set((state: pbnstPrfmncState) => ({
...state,
prfmnc: {