From e314369cbb77f083abc2ab5a6b2f588ea2dc1657 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Tue, 8 Jul 2025 19:54:53 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4=EC=9A=A9?= =?UTF-8?q?=EC=8B=9C=EC=84=A4=20=EB=93=B1=EB=A1=9D=20=EC=8B=9C=EC=84=A4/?= =?UTF-8?q?=EC=B0=A8=EC=88=98=EB=B3=84=20=EC=A0=95=EB=B3=B4=20=EA=B3=A0?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 103 +++++++++--------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 6a9189876..29b65c9c8 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -93,7 +93,7 @@ export default function PublicReuseFaciltyInsert() { if (!isDirty) { toast.error("변경사항이 없습니다."); // 변경사항이 없으면 메시지 표시 return; - } const data = writeRgtrAndMdfr(valuse.items); + } const data = writeRgtrAndMdfr(valuse.items); let bizs = [] as fcBizType[]; data.forEach((fclt) => { bizs = [...bizs, ...fclt.fcBizs]; @@ -118,22 +118,22 @@ export default function PublicReuseFaciltyInsert() { ]).then(([resFclt, resBiz]) => { const isFcltSuccess = resFclt.status === "fulfilled"; const isBizSuccess = resBiz.status === "fulfilled"; - + if (isFcltSuccess && isBizSuccess) { - toast.success('하수 재이용 시설 및 사업이 수정되었습니다. ') + toast.success('하수 재이용 시설 및 사업이 수정되었습니다. ') // 메시지 표시, 페이지 이동 등 } else { - let message ='' + let message = '' // ✅ 각각 어떤 항목이 실패했는지도 로그/알림 처리 if (!isFcltSuccess) { message = '하수재이용 시설 ' } if (!isBizSuccess) { - message += '하수재이용 시설 사업 ' + message += '하수재이용 시설 사업 ' } - - toast.error(message+'오류 입니다 ') + + toast.error(message + '오류 입니다 ') pubHasuInit("1", "41"); } @@ -146,45 +146,45 @@ export default function PublicReuseFaciltyInsert() { // 폼 유효성 검사 실패 시 호출될 함수 const onInvalid = (errors: FieldErrors<{ items: z.infer[] }>) => { console.log("errors:", errors); - + const findAllErrors = ( errorObject: any, 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 (value.message) { 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 prefix = ""; - + const itemsIndex = path.indexOf("items"); - + if (itemsIndex > -1 && path.length > itemsIndex + 1) { const itemIdx = path[itemsIndex + 1] as number; 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; @@ -194,7 +194,7 @@ export default function PublicReuseFaciltyInsert() { } } } - + // 최종 오류 메시지 출력 toast.error(`${prefix}${message}`); }); @@ -239,7 +239,7 @@ export default function PublicReuseFaciltyInsert() { } }, [indexMng]); - + useEffect(() => { @@ -266,7 +266,7 @@ export default function PublicReuseFaciltyInsert() { // ] as fcBizType[], // }) // ); - append(createDefaultPbnstItem(selecTableRow, pbnstRes.length)); + append(createDefaultPbnstItem(selecTableRow, pbnstRes.length)); setIsRuseReg({ isModal: true }); } @@ -366,24 +366,24 @@ export default function PublicReuseFaciltyInsert() { - - {formWatch && formWatch[0]?.pbnstRuseFcltPk ? ( - - - - 시설정보 - - - 차수별정보 - - - + {formWatch && formWatch[0]?.pbnstRuseFcltPk ? ( + + + + 시설정보 + + + 차수별정보 + + + + - - ) : ( - <> + + + + ) : ( + <>
- 등록된 재이용시설 정보가 없습니다. + 등록된 재이용시설 정보가 없습니다.
-
-

- 신규등록 버튼을 클릭하여 재이용시설을 등록해주세요. -

- -
- + + - )} - + )}
} bodyClass="w-[68vw] max-w-none h-[90vh]"