하수재이용시설 등록 시설/차수별 정보 고정
This commit is contained in:
@@ -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<typeof pbnstRegZod>[] }>) => {
|
||||
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() {
|
||||
</ListDiv>
|
||||
</div>
|
||||
<ListDiv className="col-span-2 pr-6 ">
|
||||
<ScrollArea className="h-[60vh]">
|
||||
{formWatch && formWatch[0]?.pbnstRuseFcltPk ? (
|
||||
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="mng">
|
||||
시설정보
|
||||
</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="buse">
|
||||
차수별정보
|
||||
</TabsTrigger>
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={form.handleSubmit(onSubmit, onInvalid)}
|
||||
className="!justify-end" // 저장 버튼 위치 조정
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
</TabsList>
|
||||
{formWatch && formWatch[0]?.pbnstRuseFcltPk ? (
|
||||
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="mng">
|
||||
시설정보
|
||||
</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="buse">
|
||||
차수별정보
|
||||
</TabsTrigger>
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={form.handleSubmit(onSubmit, onInvalid)}
|
||||
className="!justify-end" // 저장 버튼 위치 조정
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
</TabsList>
|
||||
<ScrollArea className="h-[60vh]">
|
||||
<TabsContent className="max-h-full" value="mng">
|
||||
<PbnstMngForm
|
||||
formType="update"
|
||||
@@ -406,17 +406,19 @@ export default function PublicReuseFaciltyInsert() {
|
||||
indexBiz={indexBiz}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
) : (
|
||||
<>
|
||||
|
||||
</ScrollArea>
|
||||
</Tabs>
|
||||
) : (
|
||||
<>
|
||||
<div className="card-header text-2xl">
|
||||
등록된 재이용시설 정보가 없습니다.
|
||||
등록된 재이용시설 정보가 없습니다.
|
||||
</div>
|
||||
<div className="!mx-[1.6rem] !p-0r flex flex-col items-center justify-center h-64 border rounded-md">
|
||||
<p className="text-3xl mb-4">
|
||||
신규등록 버튼을 클릭하여 재이용시설을 등록해주세요.
|
||||
</p>
|
||||
<Button
|
||||
<div className="!mx-[1.6rem] !p-0r flex flex-col items-center justify-center h-64 border rounded-md">
|
||||
<p className="text-3xl mb-4">
|
||||
신규등록 버튼을 클릭하여 재이용시설을 등록해주세요.
|
||||
</p>
|
||||
<Button
|
||||
size={"sm"}
|
||||
className=""
|
||||
onClick={() => {
|
||||
@@ -433,11 +435,10 @@ export default function PublicReuseFaciltyInsert() {
|
||||
>
|
||||
신규등록
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
</>
|
||||
|
||||
)}
|
||||
</ScrollArea>
|
||||
)}
|
||||
</ListDiv>
|
||||
<UiModal
|
||||
body={
|
||||
@@ -450,7 +451,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
}
|
||||
}}
|
||||
|
||||
onInvalid ={onInvalid}
|
||||
onInvalid={onInvalid}
|
||||
></PbnstRegModal>
|
||||
}
|
||||
bodyClass="w-[68vw] max-w-none h-[90vh]"
|
||||
|
||||
Reference in New Issue
Block a user