diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index ea7eee5c8..e4bedff60 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -54,6 +54,7 @@ export type pubFacState = { pbnsUpdateIndex: pbnstInsertIndex; fcOrgwtsNmList:pubHasuType[]; dmdComList: any[]; + apiMessage:string; }; }; type pubFacActions = { @@ -94,6 +95,7 @@ export const pubFacStateExport: pubFacState = { pbnsUpdateIndex: {} as pbnstInsertIndex, fcOrgwtsNmList:[], dmdComList: [], + apiMessage:'' }, }; @@ -269,8 +271,13 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { ruseRes ); + if(response){ + + toast.success(` 하수재이용 시설 정보가 수정되었습니다.`); + } } catch (error) { console.error("Error pbnstRuseFcltUpdate:", error); + toast.error(` 하수재이용 시설 정보가 수정오류입니다.`); } } ,pbnstRuseBizUpdate : async(ruseRes:fcBizType[])=>{ try { @@ -280,6 +287,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { `/reuseFc/pubFcBiz`, ruseRes ); + + if(response){ + toast.success(` 하수재이용 시설 사업이 수정되었습니다.`); + } const pbnstRes = await hasuListFetch("11", "11"); return set((state: pubFacState) => ({ @@ -292,6 +303,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { })); } catch (error) { console.error("Error pbnstRuseFcltUpdate:", error); + toast.error(` 하수재이용 시설 사업이 수정이 실패되엇습니다..`); } } , getBizCycle: async (pbnstObj: customPbnst) => { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index b908750fd..a111b6c10 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -236,10 +236,17 @@ export const fcBizSchema = z.object({ export const pbnstRegZod = z.object({ pbnstRuseFcltPk: z.string().default(""), swtrmtFcltFk: z.string().default(""), - ruseUtztnFcltNm: z.string().default(""), - fcltCpct: zNumDefaultZero, - ruseCpct: zNumDefaultZero, - splyExtraCpct: zNumDefaultZero, + ruseUtztnFcltNm: z + .preprocess( + (v) => (v != null ? String(v).trim() : ""), + z.string() + ) + .refine((val) => val.length > 0, { + message: "시설 이름을 입력하세요", + }), + fcltCpct: z.number(), + ruseCpct: z.number(), + splyExtraCpct: z.number(), regDt: zDateDefaultNow, rgtr: z.string().default("test"), mdfcnDt: zDateDefaultNow, diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx index d4cfebfca..6ceb75531 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx @@ -34,7 +34,7 @@ export const rainZod = z.object({ bdstNm: z.string().default(""), frstArchPrmsnDt: z.date().default(() => new Date()), archChgPrmsnDt: z.coerce.date().nullish().default(null), - archArea: z.number().default(0), + archArea: z.string().default(''), archChgArea: z.number().default(0), rgtr:z.string().nullish(), mdfr:z.string().nullish(), diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx index df9c3b543..d39412d8d 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx @@ -5,11 +5,12 @@ import type { TableUpperProps } from "@/app/store/common/type/header"; import { z } from "zod"; import { baseReuseBuildingSchema, chgBuildingSchema, validationMessages } from "../rainReg/type"; import { makeMdfr, makeRstr } from "../bdstReg"; +import toast from "react-hot-toast"; const rswtrObjSchema = z.object({ bdstRuseFcltFk: z.number().nullish(), - wtrUsqty: z.number({ required_error: validationMessages.required("물사용량(m³)") }).positive({ message: validationMessages.required("물사용량(m³)") }), - oblgTrgtWtrUsqty: z.number().nullish().default(0), + //wtrUsqty: z.number({ required_error: validationMessages.required("물사용량(m³)") }).positive({ message: validationMessages.required("물사용량(m³)") }), + //oblgTrgtWtrUsqty: z.number().nullish().default(0), orgwtKndCd: z.string({ required_error: validationMessages.requiredSelect("원수 종류") }).min(1, { message: validationMessages.requiredSelect("원수 종류") }), filtrTrtmfctCpct: z.number({ required_error: validationMessages.required("처리시설 용량") }), filtrTrtmfctProcs: z.string({ required_error: validationMessages.required("주요처리공정") }).min(1, { message: validationMessages.required("주요처리공정") }), @@ -36,7 +37,7 @@ export const rswtZod = z.object({ frstArchPrmsnDt: z.date().default(() => new Date()), archChgPrmsnDt: z.coerce.date().nullish().default(null), chBuildingYn: z.string().nullish(), - archArea: z.number().default(0), + archArea: z.string().default(''), archChgArea: z.number().default(0), rgtr: z.string().nullish().default(null), mdfr: z.string().nullish().default(null), @@ -152,8 +153,8 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( try { const chData = await makeMdfr(data); const res = await putFectch("/reuseFc/waterreuseFc", chData); - if (res.ok) { - alert("등록이 완료되었습니다."); + if (res.status ===200) { + toast.success("중수도 건축물 수정이 완료되었습니다."); const rswtRes = await initFetch(code); set((state: rswtFacState) => ({ ...state, @@ -165,10 +166,8 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( })); } } catch (errorUpdate) { - alert( - "업데이트 오류입니다. " + - (errorUpdate instanceof Error ? errorUpdate.message : "") - ); + toast.error("중수도 건축물 수정 오류입니다. "); + } finally { } }, @@ -176,29 +175,28 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( try { const chData = await makeRstr(data); const res = await postFectch("/reuseFc/waterreuseFc", chData); - if (res.ok) { - if (data.chgBuilding.length > 0) { - await res - .json() - .then((resData: any) => { - const chPK = resData?.data?.bdstInfoPk; - const makeCh = resData.data.chgBuilding.map( - (item: chgBuilding) => ({ - ...item, - bdstInfoFk: chPK, - }) - ); - const chch = postFectch("/reuseFc/chgBuilding", makeCh); - return chch; - }) - .then((chch: any) => { - if (chch.ok) { - alert("등록이 완료되었습니다."); - } - }); + if (res.status===200) { + if(data.chgBuilding.length > 0){ + + const chPK = res?.data?.bdstInfoPk + const makeCh= res.data.chgBuilding.map((item: chgBuilding) => + ( { + ...item, + bdstInfoFk: chPK, + }) + ); + const chch= await postFectch("/reuseFc/chgBuilding", makeCh); + + if(chch.status ===200) { + toast.success("건축물 등록이 완료되었습니다."); + }else{ + toast.error("건축물 증축/개축/중축 오류입니다."); + } } else { - alert("등록이 완료되었습니다."); + toast.success("건축물 등록이 완료되었습니다."); } + }else{ + toast.error("건축물 등록이 완료되었습니다."); } const rainRes = await initFetch(code); set((state: rswtFacState) => ({ @@ -211,7 +209,7 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( })); } catch (e) { console.log("e", e); - alert("등록 오류입니다."); + toast.error("등록시 오류가 발생하였습니다."); } finally { } },