diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index acc72ea0f..6b45dacc9 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -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}`); }); } }; diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx index 87e827f60..82f2ed59c 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx @@ -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: {