입력 밸류데이션의 재이용 시설명 추가
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user