wr: store toast 변경
This commit is contained in:
@@ -157,7 +157,8 @@ export default function RuseRvwHstry() {
|
||||
|
||||
if (completeData && completeData?.length > 0) {
|
||||
if (await confirm(t("isMatchFinishMsg"))) {
|
||||
await ruseRvwComplete(completeData as number[]);
|
||||
const message = await ruseRvwComplete(completeData as number[]);
|
||||
alert(message);
|
||||
}
|
||||
|
||||
// const handleConfirm = async () => {
|
||||
|
||||
@@ -450,7 +450,10 @@ export default function PublicReuseFaciltyInsert() {
|
||||
form={form} // form prop 전달
|
||||
setPbnstInsert={(data) => {
|
||||
if (data) {
|
||||
pbnstInsert(data); // pbnstInsert 함수 호출
|
||||
void (async () => {
|
||||
const message = await pbnstInsert(data);
|
||||
alert(message);
|
||||
})();
|
||||
setIsRuseReg({ isModal: false });
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -242,14 +242,16 @@ export default function Page() {
|
||||
if (data.length > 0) {
|
||||
if (selFcltDiv === "RNB") {
|
||||
const handleConfirm = async () => {
|
||||
rainChkDelete(data, searchYear);
|
||||
const message = await rainChkDelete(data, searchYear);
|
||||
alert(message);
|
||||
};
|
||||
if (await confirm(t("isDeleteMsg"))) {
|
||||
await handleConfirm();
|
||||
}
|
||||
} else {
|
||||
const handleConfirm = async () => {
|
||||
rswtChkDelete(data, searchYear);
|
||||
const message = await rswtChkDelete(data, searchYear);
|
||||
alert(message);
|
||||
};
|
||||
if (await confirm(t("isDeleteMsg"))) {
|
||||
await handleConfirm();
|
||||
@@ -257,16 +259,18 @@ export default function Page() {
|
||||
}
|
||||
}
|
||||
};
|
||||
const chkUpdateTable = (selFcltDiv: string) => {
|
||||
const chkUpdateTable = async (selFcltDiv: string) => {
|
||||
if (selFcltDiv === "RNB") {
|
||||
if (updateRainDetail && updateRainDetail.length > 0) {
|
||||
rainChkDetilUpdate(updateRainDetail, searchYear);
|
||||
const message = await rainChkDetilUpdate(updateRainDetail, searchYear);
|
||||
alert(message);
|
||||
} else {
|
||||
alert("수정을 원하는 행을 선택하고 저장버튼을 눌러주세요 ");
|
||||
}
|
||||
} else {
|
||||
if (updateRswtDetail && updateRswtDetail.length > 0) {
|
||||
rswtChkDetilsUpdate(updateRswtDetail, searchYear);
|
||||
const message = await rswtChkDetilsUpdate(updateRswtDetail, searchYear);
|
||||
alert(message);
|
||||
} else {
|
||||
alert("수정을 원하는 행을 선택하고 저장버튼을 눌러주세요 ");
|
||||
}
|
||||
@@ -349,7 +353,7 @@ export default function Page() {
|
||||
<Button
|
||||
className={btnClass}
|
||||
onClick={() => {
|
||||
chkUpdateTable(selFcltDiv);
|
||||
void chkUpdateTable(selFcltDiv);
|
||||
}}
|
||||
disabled={mdfcnAuthrtYn === 'N'}
|
||||
>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { fetchType, getFetchWithCount, postFectch, putFectch } from "@/components/lib/api";
|
||||
import toast from "react-hot-toast";
|
||||
import type {
|
||||
TableUpperProps
|
||||
} from "../../common/type/header";
|
||||
@@ -52,7 +51,7 @@ type ruseHstryActions = {
|
||||
endYear: string,
|
||||
sggCd?: string
|
||||
) => void;
|
||||
ruseRvwCalUpdate: (data: DmdCoReqType) => void;
|
||||
ruseRvwCalUpdate: (data: DmdCoReqType) => Promise<string>;
|
||||
ruseRvwSearch: (
|
||||
pageNo: number,
|
||||
pageCnt: number,
|
||||
@@ -69,7 +68,7 @@ type ruseHstryActions = {
|
||||
endYear: string,
|
||||
sggCd: string
|
||||
) => void;
|
||||
ruseRvwComplete:( data: number[]) => void;
|
||||
ruseRvwComplete:( data: number[]) => Promise<string>;
|
||||
};
|
||||
|
||||
const irvwHistInit = async (
|
||||
@@ -119,6 +118,8 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
}));
|
||||
},
|
||||
ruseRvwCalUpdate: async (data: DmdCoReqType) => {
|
||||
const successMessage = "매칭 계산 저장이 완료입니다.";
|
||||
const failMessage = "매칭 계산 저장이 오류입니다.";
|
||||
try {
|
||||
|
||||
const updatedData = addRgtrAndMdfrToDemandObj(data);
|
||||
@@ -127,14 +128,13 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
updatedData
|
||||
);
|
||||
if (update.status === 200) {
|
||||
toast.success("매칭 계산 저장이 완료입니다.");
|
||||
const rvwHistRes = await irvwHistInit(
|
||||
1,
|
||||
13,
|
||||
new Date().getFullYear().toString(),
|
||||
new Date().getFullYear().toString(),
|
||||
);
|
||||
return set((state: ruseHstryState) => ({
|
||||
set((state: ruseHstryState) => ({
|
||||
...state,
|
||||
ruseHist: {
|
||||
...state.ruseHist,
|
||||
@@ -142,10 +142,12 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
rvwHistRes: rvwHistRes.data,
|
||||
rvwHistCount:rvwHistRes.count },
|
||||
}));
|
||||
return successMessage;
|
||||
}
|
||||
return failMessage;
|
||||
} catch (e) {
|
||||
toast.error("매칭 계산 저장이 오류입니다.");
|
||||
console.log(e);
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
ruseRvwSearch: async (
|
||||
@@ -210,6 +212,8 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
}
|
||||
},
|
||||
ruseRvwComplete: async (data: number[]) => {
|
||||
const successMessage = "매칭완료가 완료되었습니다.";
|
||||
const failMessage = "매칭 완료 처리 중 오류가 발생했습니다.";
|
||||
try {
|
||||
const complet = await postFectch(
|
||||
`/reuseFc/request/completeCheck`,
|
||||
@@ -217,7 +221,6 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
fetchType.WR
|
||||
);
|
||||
if (complet.status === 200) {
|
||||
toast.success("매칭완료가 완료되었습니다.");
|
||||
const rvwHistRes = await irvwHistInit(
|
||||
1,
|
||||
13,
|
||||
@@ -225,7 +228,7 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
new Date().getFullYear().toString(),
|
||||
);
|
||||
|
||||
return set((state: ruseHstryState) => ({
|
||||
set((state: ruseHstryState) => ({
|
||||
...state,
|
||||
ruseHist: {
|
||||
...state.ruseHist,
|
||||
@@ -233,10 +236,12 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
rvwHistCount:rvwHistRes.count
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
}
|
||||
return failMessage;
|
||||
} catch (e) {
|
||||
console.log(" error ", e);
|
||||
toast.error("매칭 완료 처리 중 오류가 발생했습니다.");
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import type { SelectDataType } from "@common/business_components";
|
||||
import type { rainChkZodType } from ".";
|
||||
import {
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
isInvalidNumber,
|
||||
parseRawValue,
|
||||
} from "@/components/lib/func/excelFunc";
|
||||
import toast from "react-hot-toast";
|
||||
import { codeToText, textToCode } from "@/components/lib/func/common";
|
||||
export const useTypes = [
|
||||
"조경용수",
|
||||
@@ -232,14 +231,21 @@ export const excelToRainChkData = (excelData: any, year: string) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
toast.error("데이터가 없습니다. 점검 데이터를 확인해주세요.");
|
||||
}
|
||||
|
||||
if (issues.length > 0) {
|
||||
return { rainChkgdData: [], issues };
|
||||
return { rainChkgdData: [], issues, message: "" };
|
||||
}
|
||||
|
||||
return { rainChkgdData, issues: [] };
|
||||
if (rainChkgdData.length === 0) {
|
||||
return {
|
||||
rainChkgdData: [],
|
||||
issues: [],
|
||||
message: "데이터가 없습니다. 점검 데이터를 확인해주세요.",
|
||||
};
|
||||
}
|
||||
|
||||
return { rainChkgdData, issues: [], message: "" };
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { buildingType } from "@/app/store/common/code";
|
||||
import { buildingType } from "@/app/store/common/code";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import {
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
putFectch,
|
||||
} from "@/components/lib/api";
|
||||
import type { SelectDataType } from "@common/business_components/ui";
|
||||
import toast from "react-hot-toast";
|
||||
import { z } from "zod";
|
||||
import { buildingToExcelType } from "./excel";
|
||||
import {
|
||||
@@ -67,15 +66,15 @@ type rainChkgdnActions = {
|
||||
sggCd: string,
|
||||
searchTxt: string
|
||||
) => void;
|
||||
rainChkDetilUpdate(rainChk: rainChkZodType[] ,year:string) : Promise<void>;
|
||||
rainChkGuidUpdate(rainChk: rainChkZodType): Promise<void>;
|
||||
rainChkDetilUpdate(rainChk: rainChkZodType[] ,year:string) : Promise<string>;
|
||||
rainChkGuidUpdate(rainChk: rainChkZodType): Promise<string>;
|
||||
rainChkExcelDownload(
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[],
|
||||
sggCd:string
|
||||
): Promise<void>;
|
||||
rainChkExcelDataUPload(excelData: rainChkZodType[] ,year :string,laeSeCd:string) : Promise<void>;
|
||||
rainChkDelete(chkgdnSns: number[] ,year :string): Promise<void>;
|
||||
rainChkExcelDataUPload(excelData: rainChkZodType[] ,year :string,laeSeCd:string) : Promise<string>;
|
||||
rainChkDelete(chkgdnSns: number[] ,year :string): Promise<string>;
|
||||
rainChkHeadChange: (rainChkgdn: rainChkgdnState, isEdit: boolean) => void;
|
||||
rainChkNmSearch: (
|
||||
pageNo: number,
|
||||
@@ -168,6 +167,8 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
}));
|
||||
},
|
||||
rainChkExcelDataUPload: async (excelData: rainChkZodType[] ,year:string,laeSeCd:string) => {
|
||||
const successMessage = "지도점검 등록이 완료되었습니다.";
|
||||
const failMessage = "지도점검 등록이 실패되었습니다.";
|
||||
set((state: rainChkgdnType) => (
|
||||
{ rainChkgdn: { ...state.rainChkgdn, isLoading: true } }));
|
||||
try {
|
||||
@@ -187,13 +188,12 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
rainChkCount: rainChkRes.count,
|
||||
},
|
||||
}));
|
||||
toast.success("지도점검 등록이 완료되었습니다.");
|
||||
} else {
|
||||
toast.error("지도점검 등록이 실패되었습니다.");
|
||||
return successMessage;
|
||||
}
|
||||
return failMessage;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
toast.error("지도점검 등록이 실패되었습니다.");
|
||||
return failMessage;
|
||||
} finally {
|
||||
set((state: rainChkgdnType) => ({ rainChkgdn: { ...state.rainChkgdn, isLoading: false } }));
|
||||
}
|
||||
@@ -257,21 +257,20 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
}
|
||||
},
|
||||
rainChkDetilUpdate: async (rainChk: rainChkZodType[] ,year:string) => {
|
||||
const successMessage = "지도점검 대체수 및 빗물이용량 수정이 완료되었습니다. ";
|
||||
const failMessage = "지도점검 대체수 및 빗물이용량 수정 오류입니다.";
|
||||
try {
|
||||
const chData = await makeMdfrChk(rainChk, "rain");
|
||||
|
||||
const res = await putFectch("/reuseChk/rainy/list", chData);
|
||||
if (res) {
|
||||
toast.success(
|
||||
"지도점검 대체수 및 빗물이용량 수정이 완료되었습니다. "
|
||||
);
|
||||
const rainChkRes = await initFetch(
|
||||
1,
|
||||
rainPageSize,
|
||||
year,
|
||||
"41"
|
||||
);
|
||||
return set((state: rainChkgdnState) => ({
|
||||
set((state: rainChkgdnState) => ({
|
||||
...state,
|
||||
rainChkgdn: {
|
||||
...state.rainChkgdn,
|
||||
@@ -279,21 +278,20 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
rainChkCount: rainChkRes.count,
|
||||
},
|
||||
}));
|
||||
} else {
|
||||
toast.error("지도점검 대체수 및 빗물이용량 수정 오류입니다.");
|
||||
return successMessage;
|
||||
}
|
||||
return failMessage;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
toast.error("지도점검 대체수 및 빗물이용량 수정 오류입니다.");
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
rainChkGuidUpdate: async (rainChk: rainChkZodType) => {
|
||||
const successMessage = "지도점검 수질 및 과태료 수정이 완료되었습니다. ";
|
||||
const failMessage = "지도점검 수질 및 과태료 수정 오류입니다.";
|
||||
try {
|
||||
//const chData = await makeMdfrChk(rainChk, "guideDetails", "rainDetil");
|
||||
const res = await putFectch("/reuseChk/rainy", rainChk);
|
||||
if (res.status === 200) {
|
||||
toast.success("지도점검 수질 및 과태료 수정이 완료되었습니다. ");
|
||||
|
||||
const currentYear = new Date().getFullYear().toString();
|
||||
const rainChkRes = await initFetch(
|
||||
1,
|
||||
@@ -301,7 +299,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
currentYear,
|
||||
"41"
|
||||
);
|
||||
return set((state: rainChkgdnState) => ({
|
||||
set((state: rainChkgdnState) => ({
|
||||
...state,
|
||||
rainChkgdn: {
|
||||
...state.rainChkgdn,
|
||||
@@ -309,29 +307,28 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
rainChkCount: rainChkRes.count,
|
||||
},
|
||||
}));
|
||||
} else {
|
||||
toast.error("지도점검 수질 및 과태료 수정 오류입니다.");
|
||||
|
||||
return successMessage;
|
||||
}
|
||||
return failMessage;
|
||||
} catch (error) {
|
||||
console.log(' 지도점검 수질 및 과태료 수정 오류', error)
|
||||
toast.error("지도점검 수질 및 과태료 수정 오류입니다.");
|
||||
console.log(" 지도점검 수질 및 과태료 수정 오류", error);
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
rainChkDelete: async (chkgdnSns: number[] ,year :string) => {
|
||||
const successMessage = "삭제가 완료되었습니다. ";
|
||||
const failMessage = "삭제시 오류가 발생하였습니다.. ";
|
||||
try {
|
||||
const res = await deleteFectch(`/reuseChk/rainy`, chkgdnSns);
|
||||
|
||||
if (res) {
|
||||
toast.success("삭제가 완료되었습니다. ");
|
||||
|
||||
const rainChkRes = await initFetch(
|
||||
1,
|
||||
rainPageSize,
|
||||
year,
|
||||
"41"
|
||||
);
|
||||
return set((state: rainChkgdnState) => ({
|
||||
set((state: rainChkgdnState) => ({
|
||||
...state,
|
||||
rainChkgdn: {
|
||||
...state.rainChkgdn,
|
||||
@@ -339,14 +336,12 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
rainChkCount: rainChkRes.count,
|
||||
},
|
||||
}));
|
||||
} else {
|
||||
toast.error("삭제시 오류가 발생하였습니다.. ");
|
||||
|
||||
return successMessage;
|
||||
}
|
||||
return failMessage;
|
||||
} catch (error) {
|
||||
console.log(' 삭제시 오류가 발생하였습니다', error)
|
||||
|
||||
toast.error("삭제시 오류가 발생하였습니다.. ");
|
||||
console.log(" 삭제시 오류가 발생하였습니다.", error);
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
rainChkHeadChange: async (rainChkgdn: rainChkgdnState, isEdit: boolean) => {
|
||||
@@ -391,3 +386,4 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { buildingType } from "@/app/store/common/code";
|
||||
import { buildingType } from "@/app/store/common/code";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import {
|
||||
TEST_UUID,
|
||||
@@ -11,12 +11,10 @@ import {
|
||||
postFectch,
|
||||
putFectch,
|
||||
} from "@/components/lib/api";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import type {
|
||||
SelectDataType,
|
||||
SheetParameter,
|
||||
} from "@common/business_components";
|
||||
import toast from "react-hot-toast";
|
||||
import { z } from "zod";
|
||||
import { type chHeadType } from "../rainChkgdn/headList";
|
||||
import { rswtMakeExcelSample } from "./excel";
|
||||
@@ -78,12 +76,12 @@ type rswtChkgdnActions = {
|
||||
sggCode: SelectDataType[],
|
||||
sggCd: string,
|
||||
): Promise<void>;
|
||||
rswtChkExceDataUpload: (excelData: rswtChkZodType[],laeSeCd:string) => void;
|
||||
rswtChkDelete: (chkgdnSns: number[] ,year:string) => void;
|
||||
rswtChkDetilsUpdate: (rswtChkDetails: rswtrChkDetailsZodType[] ,year:string) => void;
|
||||
rswtChkExceDataUpload: (excelData: rswtChkZodType[],laeSeCd:string) => Promise<string>;
|
||||
rswtChkDelete: (chkgdnSns: number[] ,year:string) => Promise<string>;
|
||||
rswtChkDetilsUpdate: (rswtChkDetails: rswtrChkDetailsZodType[] ,year:string) => Promise<string>;
|
||||
rswtChkPolAndGuide: (chkgdnSn: number) => void;
|
||||
rswtChkPolInit: () => void;
|
||||
rwstPolAndGuideUpdate: (rswtChk: rswtChkZodType[]) => void;
|
||||
rwstPolAndGuideUpdate: (rswtChk: rswtChkZodType[]) => Promise<string>;
|
||||
rswtChkHeadChange: (rswtChkgdn: rswtChkgdnState, isEdit: boolean) => void;
|
||||
setRswtChkLoading:(status:boolean) =>void
|
||||
};
|
||||
@@ -245,19 +243,18 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
}
|
||||
},
|
||||
rswtChkExceDataUpload: async (excelData: rswtChkZodType[],laeSeCd:string) => {
|
||||
const successMessage = "지도점검 등록이 완료되었습니다.";
|
||||
const failMessage = "지도점검 등록이 실패되었습니다.";
|
||||
try {
|
||||
set((state: rswtChkgdnType) => (
|
||||
{ rswtChkgdn: { ...state.rswtChkgdn, isLoading: true } }));
|
||||
const res = await postFectch("/reuseChk/reuseWater", excelData);
|
||||
if (res.ok) {
|
||||
ToastFormUi({
|
||||
body: "지도점검 등록이 완료되었습니다.",
|
||||
title: "지도점검 등록",
|
||||
});
|
||||
if (!res.ok) {
|
||||
return failMessage;
|
||||
}
|
||||
const currentYear = new Date().getFullYear().toString();
|
||||
const rswtChkRes = await initFetch(1, rswtPageSize, currentYear, laeSeCd);
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
@@ -265,8 +262,10 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
rswtChkCount: rswtChkRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return failMessage;
|
||||
}finally{
|
||||
set((state: rswtChkgdnType) => (
|
||||
{ rswtChkgdn: { ...state.rswtChkgdn, isLoading: false } }));
|
||||
@@ -274,15 +273,17 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
|
||||
},
|
||||
rswtChkDetilsUpdate: async (rswtChk: rswtrChkDetailsZodType[] ,year:string) => {
|
||||
const successMessage = "지도점검 과태료 수정이 완료되었습니다. ";
|
||||
const failMessage = "지도점검 과태료 수정 오류입니다. ";
|
||||
try {
|
||||
const chData = await makeMdfrChk(rswtChk);
|
||||
|
||||
const res = await putFectch("/reuseChk/reuseWater", chData);
|
||||
if (res.ok) {
|
||||
toast.success("지도점검 과태료 수정이 완료되었습니다. ",)
|
||||
if (!res.ok) {
|
||||
return failMessage;
|
||||
}
|
||||
const rswtChkRes = await initFetch(1, rswtPageSize, year, "0");
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
@@ -291,21 +292,24 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
toast.error("지도점검 과태료 수정 오류입니다. ",)
|
||||
return failMessage;
|
||||
|
||||
}
|
||||
},
|
||||
rswtChkDelete: async (chkgdnSns: number[] ,year:string) => {
|
||||
const successMessage = "삭제가 완료되었습니다.";
|
||||
const failMessage = "삭제 오류입니다.";
|
||||
try {
|
||||
const res = await deleteFectch(`/reuseChk/reuseWater`, chkgdnSns);
|
||||
|
||||
if (res) {
|
||||
toast.success("삭제가 완료되었습니다.")
|
||||
if (!res) {
|
||||
return failMessage;
|
||||
}
|
||||
const rswtChkRes = await initFetch(1, rswtPageSize, year, "0");
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
@@ -313,9 +317,10 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
rswtChkCount: rswtChkRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (error) {
|
||||
toast.error("삭제 오류입니다.")
|
||||
console.error(error);
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
rswtChkPolAndGuide: async (chkgdnSn: number) => {
|
||||
@@ -350,18 +355,20 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
}
|
||||
},
|
||||
rwstPolAndGuideUpdate: async (rswtChk: rswtChkZodType[]) => {
|
||||
const successMessage = "지도점검 연간 수질 및 대체수/중수도 수정이 완료되었습니다.";
|
||||
const failMessage = "지도점검 연간 수질 및 대체수/중수도 수정 오류입니다.";
|
||||
try {
|
||||
const chData = await makeMdfrChk(rswtChk);
|
||||
const res = await putFectch(
|
||||
`/reuseChk/reuseWater/${rswtChk[0]?.chkgdnSn}`,
|
||||
chData[0]
|
||||
);
|
||||
if (res.ok) {
|
||||
toast.success("지도점검 연간 수질 및 대체수/중수도 수정이 완료되었습니다.")
|
||||
if (!res.ok) {
|
||||
return failMessage;
|
||||
}
|
||||
const currentYear = new Date().getFullYear().toString();
|
||||
const rswtChkRes = await initFetch(1, rswtPageSize, currentYear, "0");
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
@@ -369,10 +376,11 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
rswtChkCount: rswtChkRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
toast.error("지도점검 연간 수질 및 대체수/중수도 수정 오류입니다.")
|
||||
return failMessage;
|
||||
|
||||
}
|
||||
},
|
||||
@@ -409,3 +417,4 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { getFetchWithCount, postFectch, putFectch, deleteFectch } from "@/components/lib/api";
|
||||
import { getFetchWithCount, postFectch, putFectch, deleteFectch } from "@/components/lib/api";
|
||||
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import toast from "react-hot-toast";
|
||||
import { z } from "zod";
|
||||
import { makeMdfr, makeRstr } from "../bdstReg";
|
||||
import {
|
||||
@@ -100,9 +99,9 @@ export type htdflFacState = {
|
||||
type htdflFacSActions = {
|
||||
initHtdflReg: (code: string) => void;
|
||||
htdflNmSearch: (code: string | number, fcltNm:string) => void;
|
||||
htdflBdstUpdate: (data: customHtdflBdst, code: string | number,myUUID:string) => void;
|
||||
htdflBdstReg: (data: customHtdflBdst, code: string | number,myUUID:string) => void;
|
||||
htdflBdstDelete: (data: customHtdflBdst, code: string | number) => void;
|
||||
htdflBdstUpdate: (data: customHtdflBdst, code: string | number,myUUID:string) => Promise<string>;
|
||||
htdflBdstReg: (data: customHtdflBdst, code: string | number,myUUID:string) => Promise<string>;
|
||||
htdflBdstDelete: (data: customHtdflBdst, code: string | number) => Promise<string>;
|
||||
getHtdflBdstData: (pageNation: number, code: string | number) => void;
|
||||
resetHtdflTableIndex:(index:number)=>void;
|
||||
};
|
||||
@@ -172,11 +171,13 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
}
|
||||
},
|
||||
htdflBdstUpdate: async (data: customHtdflBdst, code: string | number,myUUID:string) => {
|
||||
const successMessage = "온배수 시설물 수정이 완료되었습니다.";
|
||||
const failMessage = "온배수 시설물 수정 오류입니다..";
|
||||
try {
|
||||
const chData = await makeMdfr(data,myUUID);
|
||||
const res = await putFectch("/drain/facility", chData);
|
||||
if (res.status) {
|
||||
toast.success("온배수 시설물 수정이 완료되었습니다.");
|
||||
if (!res.status) {
|
||||
return failMessage;
|
||||
}
|
||||
const htdflRes = await getFetchWithCount(
|
||||
"wr",
|
||||
@@ -191,20 +192,23 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (errorUpdate) {
|
||||
toast.error("온배수 시설물 수정 오류입니다..");
|
||||
console.log(errorUpdate);
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
htdflBdstReg: async (data: customHtdflBdst, code: string | number,myUUID:string) => {
|
||||
const successMessage = "온배수 시설 등록이 완료되었습니다.";
|
||||
const failMessage = "온배수 시설물 등록 오류입니다..";
|
||||
try {
|
||||
// data는 단일 객체이므로 .map을 사용할 수 없습니다.
|
||||
// 등록 시에는 건축물 변경 이력이 없으므로 chgBuilding을 빈 배열로 설정하고,
|
||||
// API가 배열을 기대하므로 단일 객체를 배열로 감싸줍니다.
|
||||
const chData = makeRstr(data,myUUID);
|
||||
const res = await postFectch("/drain/facility", chData);
|
||||
if (res.status ===200) {
|
||||
toast.success("온배수 시설 등록이 완료되었습니다.");
|
||||
if (res.status !== 200) {
|
||||
return failMessage;
|
||||
}
|
||||
const htdflRes = await initFetch(String(code));
|
||||
set((state: htdflFacState) => ({
|
||||
@@ -216,17 +220,18 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (errorReg) {
|
||||
toast.error("온배수 시설물 등록 오류입니다..");
|
||||
console.log(errorReg);
|
||||
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
// 온배수시설을 삭제한다.
|
||||
htdflBdstDelete: async (data: customHtdflBdst, code: string | number) => {
|
||||
const successMessage = `${data.bdstNm} 시설이 삭제되었습니다.`;
|
||||
const failMessage = "삭제 중 오류가 발생했습니다.";
|
||||
try {
|
||||
await deleteFectch(`/drain/facility/${data.reuseBuilding?.[0]?.bdstRuseFcltSn}`);
|
||||
toast.success(`${data.bdstNm} 시설이 삭제되었습니다.`);
|
||||
|
||||
const htdflRes = await initFetch(String(code));
|
||||
set((state: htdflFacState) => ({
|
||||
@@ -237,10 +242,10 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
htdflResCount: htdflRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
const errorMessage = e instanceof Error ? e.message : "삭제 중 오류가 발생했습니다.";
|
||||
toast.error(errorMessage);
|
||||
return e instanceof Error ? e.message : failMessage;
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
@@ -279,3 +284,4 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TEST_UUID } from "../rainReg";
|
||||
import { TEST_UUID } from "../rainReg";
|
||||
import {
|
||||
deleteFectch,
|
||||
fetchType,
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
fcOrgwtsHeadListExport,
|
||||
} from "./headList";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
/**
|
||||
* 하수재이용시설 등록 (스토어)
|
||||
@@ -67,7 +66,7 @@ type pubFacActions = {
|
||||
pubHasuInit: (page: string, sggOrCity: string) => void;
|
||||
pbnstRegClick: (pubHasuRes: pubHasuType) => void;
|
||||
//pbnstReg: (txt: string | undefined) => void;
|
||||
pbnstInsert(pbnstRes: customPbnst): Promise<void>;
|
||||
pbnstInsert(pbnstRes: customPbnst): Promise<string>;
|
||||
fileDelete: (atflCd: string) => void;
|
||||
fileDownLoad: (atflCd: string) => void;
|
||||
pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void;
|
||||
@@ -226,26 +225,28 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
},
|
||||
// 하수재이용시설을 등록한다.
|
||||
pbnstInsert: async (pbnstRes: customPbnst) => {
|
||||
const successMessage = `${pbnstRes.ruseUtztnFcltNm} 하수재이용 시설이 등록되었습니다.`;
|
||||
const failMessage = "하수재이용 시설 등록 중 오류가 발생했습니다.";
|
||||
try {
|
||||
const response = await postFectch(`/reuseFc/pubFc`, pbnstRes);
|
||||
if (response.status === 200) {
|
||||
toast.success(
|
||||
`${pbnstRes.ruseUtztnFcltNm} 하수재이용 시설이 등록되었습니다.`
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
return failMessage;
|
||||
}
|
||||
|
||||
const newPbnstRes = await initFetch(
|
||||
pbnstRes.pbnstRuseFcltId.slice(0, 11)
|
||||
);
|
||||
return set((state: pubFacState) => ({
|
||||
set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
pbnstRes: newPbnstRes,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (error) {
|
||||
console.error("Error updating pbnst:", error);
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
// 하수재이용시설을 업데이트한다.(사업제외) 다르게하는 이유는 객체가 너무커서 분활 처리하려고
|
||||
@@ -314,3 +315,4 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import {
|
||||
deleteFectch,
|
||||
fetchType,
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
postFectch,
|
||||
putFectch,
|
||||
} from "@/components/lib/api";
|
||||
import toast from "react-hot-toast";
|
||||
import { z } from "zod";
|
||||
import { makeMdfr, makeRstr } from "../bdstReg";
|
||||
import {
|
||||
@@ -96,9 +95,9 @@ type rainFacSActions = {
|
||||
initRain: (code: string | number) => void;
|
||||
getRainData: (pageNation: number, code: string | number) => void;
|
||||
rainSearch: (txt: string, pageNation: number, code: string) => void;
|
||||
rainBdstReg: (data: customRainBdst, code: string | number,myUUID:string) => void;
|
||||
rainBdstUpdate: (data: customRainBdst, code: string | number,myUUID:string) => void;
|
||||
rainBdstDelete: (data: customRainBdst, code: string | number) => void;
|
||||
rainBdstReg: (data: customRainBdst, code: string | number,myUUID:string) => Promise<string>;
|
||||
rainBdstUpdate: (data: customRainBdst, code: string | number,myUUID:string) => Promise<string>;
|
||||
rainBdstDelete: (data: customRainBdst, code: string | number) => Promise<string>;
|
||||
resetRainTableIndex:(index:number)=>void;
|
||||
};
|
||||
|
||||
@@ -187,9 +186,13 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
},
|
||||
// 빗물 이용시설을 등록한다.
|
||||
rainBdstReg: async (data: customRainBdst, code: string | number,myUUID:string) => {
|
||||
const successMessage = "건축물 등록이 완료되었습니다.";
|
||||
const failMessage = "등록시 오류가 발생하였습니다.";
|
||||
const changeBuildingFailMessage = "건축물 증축/개축/재축 오류입니다.";
|
||||
try {
|
||||
const test = await makeRstr(data,myUUID);
|
||||
const res = await postFectch("/reuseFc/rainyInfo", test);
|
||||
let message = failMessage;
|
||||
if (res.status === 200) {
|
||||
if (data.chgBuilding.length > 0) {
|
||||
const chPK = res?.data?.bdstInfoSn;
|
||||
@@ -200,15 +203,13 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
const chch = await postFectch("/reuseFc/chgBuilding", makeCh);
|
||||
|
||||
if (chch.status === 200) {
|
||||
toast.success("건축물 등록이 완료되었습니다.");
|
||||
message = successMessage;
|
||||
} else {
|
||||
toast.error("건축물 증축/개축/재축 오류입니다.");
|
||||
message = changeBuildingFailMessage;
|
||||
}
|
||||
} else {
|
||||
toast.success("건축물 등록이 완료되었습니다.");
|
||||
message = successMessage;
|
||||
}
|
||||
} else {
|
||||
toast.error("건축물 등록이 완료되었습니다.");
|
||||
}
|
||||
const rainRes = await initFetch(code);
|
||||
set((state: rainFacState) => ({
|
||||
@@ -219,17 +220,21 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
rainResCount: rainRes.count,
|
||||
},
|
||||
}));
|
||||
return message;
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
toast.error("등록시 오류가 발생하였습니다.");
|
||||
} finally {
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
// 빗물이용시설 시설에 대한 사항을 업데이트한다
|
||||
rainBdstUpdate: async (data: customRainBdst, code: string | number,myUUID:string) => {
|
||||
const successMessage = "건축물 수정이 완료되었습니다.";
|
||||
const failMessage = "수정시 오류가 발생하였습니다.";
|
||||
const changeBuildingFailMessage = "건축물 증축/개축/재축 오류입니다.";
|
||||
try {
|
||||
const chData = await makeMdfr(data,myUUID);
|
||||
const res = await putFectch("/reuseFc/rainyInfo", chData);
|
||||
let message = failMessage;
|
||||
if (res.status === 200) {
|
||||
if (data.chgBuilding.length > 0) {
|
||||
const chPK = data?.bdstInfoSn;
|
||||
@@ -240,17 +245,14 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
const chch = await postFectch("/reuseFc/chgBuilding", makeCh);
|
||||
|
||||
if (chch.status === 200) {
|
||||
toast.success("건축물 수정이 완료되었습니다.");
|
||||
message = successMessage;
|
||||
} else {
|
||||
toast.error("건축물 증축/개축/재축 오류입니다.");
|
||||
message = changeBuildingFailMessage;
|
||||
}
|
||||
} else {
|
||||
|
||||
await deleteFectch("/reuseFc/DeleteChgBuilding" , data.bdstInfoSn);
|
||||
toast.success("건축물 수정이 완료되었습니다.");
|
||||
message = successMessage;
|
||||
}
|
||||
} else {
|
||||
toast.error("건축물 수정이 완료되었습니다.");
|
||||
}
|
||||
|
||||
const rainRes = await initFetch(code);
|
||||
@@ -262,17 +264,18 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
rainResCount: rainRes.count,
|
||||
},
|
||||
}));
|
||||
return message;
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
toast.error("수정시 오류가 발생하였습니다.");
|
||||
} finally {
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
// 빗물 이용시설을 삭제한다.
|
||||
rainBdstDelete: async (data: customRainBdst, code: string | number) => {
|
||||
const successMessage = `${data.bdstNm} 시설이 삭제되었습니다.`;
|
||||
const failMessage = "삭제 중 오류가 발생했습니다.";
|
||||
try {
|
||||
await deleteFectch(`/reuseFc/rainyInfo/${data.reuseBuilding?.[0]?.bdstRuseFcltSn}`);
|
||||
toast.success(`${data.bdstNm} 시설이 삭제되었습니다.`);
|
||||
|
||||
const rainRes = await initFetch(code);
|
||||
set((state: rainFacState) => ({
|
||||
@@ -283,10 +286,10 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
rainResCount: rainRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
const errorMessage = e instanceof Error ? e.message : "삭제 중 오류가 발생했습니다.";
|
||||
toast.error(errorMessage);
|
||||
return e instanceof Error ? e.message : failMessage;
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
@@ -306,3 +309,4 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { deleteFectch, getFetchWithCount, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { deleteFectch, getFetchWithCount, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { upHeadList, type chgBuilding } from "../rainReg";
|
||||
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import toast from "react-hot-toast";
|
||||
import { z } from "zod";
|
||||
import { makeMdfr, makeRstr } from "../bdstReg";
|
||||
import { baseReuseBuildingSchema, chgBuildingSchema, validationMessages } from "../rainReg/type";
|
||||
@@ -67,15 +66,15 @@ export type rswtFacState = {
|
||||
};
|
||||
type rswtFacSActions = {
|
||||
initRswt: (code: string | number) => void;
|
||||
rswtBdstUpdate: (data: customRswtBdst, code: string | number,myUUID:string) => void;
|
||||
rswtBdstUpdate: (data: customRswtBdst, code: string | number,myUUID:string) => Promise<string>;
|
||||
getRswtBdstData: (pageNation: number, code: string | number) => void;
|
||||
rswtBdstSearch: (
|
||||
txt: string,
|
||||
pageNation: number,
|
||||
code: string | number
|
||||
) => void;
|
||||
rswtBdstReg: (data: customRswtBdst, code: string | number,myUUID:string) => void;
|
||||
rswtBdstDelete: (data: customRswtBdst, code: string | number) => void;
|
||||
rswtBdstReg: (data: customRswtBdst, code: string | number,myUUID:string) => Promise<string>;
|
||||
rswtBdstDelete: (data: customRswtBdst, code: string | number) => Promise<string>;
|
||||
resetRswtTableIndex:(index:number)=>void;
|
||||
};
|
||||
|
||||
@@ -162,9 +161,13 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
},
|
||||
// 중수도 시설에 대한 사항을 업데이트한다
|
||||
rswtBdstUpdate: async (data: customRswtBdst, code: string | number,myUUID:string) => {
|
||||
const successMessage = "중수도 건축물 수정이 완료되었습니다.";
|
||||
const failMessage = "중수도 건축물 수정 오류입니다.";
|
||||
const changeBuildingFailMessage = "중수도 건축물 증축/개축/재축 오류입니다.";
|
||||
try {
|
||||
const chData = await makeMdfr(data,myUUID);
|
||||
const res = await putFectch("/reuseFc/waterreuseFc", chData);
|
||||
let message = failMessage;
|
||||
if (res.status === 200) {
|
||||
if (data.chgBuilding.length > 0) {
|
||||
const chPK = data?.bdstInfoSn;
|
||||
@@ -177,16 +180,14 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
const chch = await postFectch("/reuseFc/chgBuilding", makeCh);
|
||||
|
||||
if (chch.status === 200) {
|
||||
toast.success("중수도 건축물 수정이 완료되었습니다.");
|
||||
message = successMessage;
|
||||
} else {
|
||||
toast.error("중수도 건축물 증축/개축/재축 오류입니다.");
|
||||
message = changeBuildingFailMessage;
|
||||
}
|
||||
} else {
|
||||
await deleteFectch("/reuseFc/DeleteChgBuilding" , data.bdstInfoSn);
|
||||
toast.success("중수도 건축물 수정이 완료되었습니다.");
|
||||
message = successMessage;
|
||||
}
|
||||
} else {
|
||||
toast.error("중수도 건축물 수정이 완료되었습니다.");
|
||||
}
|
||||
const rswtRes = await initFetch(code);
|
||||
set((state: rswtFacState) => ({
|
||||
@@ -197,18 +198,23 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
rswtResCount: rswtRes.count,
|
||||
},
|
||||
}));
|
||||
return message;
|
||||
|
||||
} catch (errorUpdate) {
|
||||
toast.error("중수도 건축물 수정 오류입니다.");
|
||||
console.error(errorUpdate);
|
||||
} finally {
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
// 중수도 시설을 등록한다.
|
||||
rswtBdstReg: async (data: customRswtBdst, code: string | number,myUUID:string) => {
|
||||
const successMessage = "건축물(중수도) 등록이 완료되었습니다.";
|
||||
const successWithChangeMessage = "건축물(중수도) 및 증축/개축/재축 등록이 완료되었습니다.";
|
||||
const failMessage = "등록시 오류가 발생하였습니다.";
|
||||
const changeBuildingFailMessage = "건축물(중수도) 증축/개축/재축 오류입니다.";
|
||||
try {
|
||||
const chData = await makeRstr(data,myUUID);
|
||||
const res = await postFectch("/reuseFc/waterreuseFc", chData);
|
||||
let message = failMessage;
|
||||
if (res.status === 200) {
|
||||
if (data.chgBuilding.length > 0) {
|
||||
|
||||
@@ -223,15 +229,13 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
|
||||
if (chch.status === 200) {
|
||||
|
||||
toast.success("건축물(중수도) 및 증축/개축/재축 등록이 완료되었습니다.");
|
||||
message = successWithChangeMessage;
|
||||
} else {
|
||||
toast.error("건축물(중수도) 증축/개축/재축 오류입니다.");
|
||||
message = changeBuildingFailMessage;
|
||||
}
|
||||
} else {
|
||||
toast.success("건축물(중수도) 등록이 완료되었습니다.");
|
||||
message = successMessage;
|
||||
}
|
||||
} else {
|
||||
toast.error("건축물(중수도) 등록이 완료하였습니다.");
|
||||
}
|
||||
const rswtRes = await initFetch(code);
|
||||
set((state: rswtFacState) => ({
|
||||
@@ -242,17 +246,18 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
rswtResCount: rswtRes.count,
|
||||
},
|
||||
}));
|
||||
return message;
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
toast.error("등록시 오류가 발생하였습니다.");
|
||||
} finally {
|
||||
return failMessage;
|
||||
}
|
||||
},
|
||||
// 중수도시설을 삭제한다.
|
||||
rswtBdstDelete: async (data: customRswtBdst, code: string | number) => {
|
||||
const successMessage = `${data.bdstNm} 시설이 삭제되었습니다.`;
|
||||
const failMessage = "삭제 중 오류가 발생했습니다.";
|
||||
try {
|
||||
await deleteFectch(`/reuseFc/waterreuseFc/${data.reuseBuilding?.[0]?.bdstRuseFcltSn}`);
|
||||
toast.success(`${data.bdstNm} 시설이 삭제되었습니다.`);
|
||||
|
||||
const rswtRes = await initFetch(code);
|
||||
set((state: rswtFacState) => ({
|
||||
@@ -263,10 +268,10 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
rswtResCount: rswtRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
const errorMessage = e instanceof Error ? e.message : "삭제 중 오류가 발생했습니다.";
|
||||
toast.error(errorMessage);
|
||||
return e instanceof Error ? e.message : failMessage;
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
@@ -286,3 +291,4 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -251,7 +251,8 @@ export default function ConCostForm({
|
||||
delete value.ruseUtztnFcltNm;
|
||||
console.log("onSubmit data ", pk);
|
||||
|
||||
ruseRvwCalUpdate(value);
|
||||
const message = await ruseRvwCalUpdate(value);
|
||||
alert(message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
handleOnlyNumberChange,
|
||||
} from "@/components/lib/func/common";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { useAlertStore } from "@/src/shared/lib";
|
||||
import {
|
||||
Form,
|
||||
FormField,
|
||||
@@ -24,7 +25,6 @@ import { Button, Input, Label, ScrollArea } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { z } from "zod";
|
||||
import BdstReg from "../bdstReg/bdstReg";
|
||||
@@ -55,6 +55,7 @@ export default function HtdflRegForm({
|
||||
});
|
||||
const { laeSeCd } = auth;
|
||||
const { confirm } = useConfirm();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [regCtpvCd, regSggcd] = form.watch(["ctpvCd", "sggCd"]);
|
||||
|
||||
@@ -66,17 +67,18 @@ export default function HtdflRegForm({
|
||||
const myUUID = await getMyUUID();
|
||||
|
||||
if (!myUUID) {
|
||||
toast.error(t('noUserInfoMsg'));
|
||||
alert(t('noUserInfoMsg'));
|
||||
return;
|
||||
}
|
||||
if (isModal) {
|
||||
const data = regCtpvCd ? regCtpvCd : regSggcd ? regSggcd : "noCd";
|
||||
if (data === "noCd") {
|
||||
toast.error("시도/시군구 코드를 선택해야합니다.");
|
||||
alert("시도/시군구 코드를 선택해야합니다.");
|
||||
return;
|
||||
}
|
||||
const handleConfirm = async () => {
|
||||
htdflBdstReg(values, data,myUUID);
|
||||
const message = await htdflBdstReg(values, data,myUUID);
|
||||
alert(message);
|
||||
if (setIsModal) setIsModal(false);
|
||||
};
|
||||
if (await confirm(t("isInsertMsg"))) {
|
||||
@@ -84,7 +86,8 @@ export default function HtdflRegForm({
|
||||
}
|
||||
} else {
|
||||
const handleConfirm = async () => {
|
||||
await htdflBdstUpdate(values, laeSeCd,myUUID);
|
||||
const message = await htdflBdstUpdate(values, laeSeCd,myUUID);
|
||||
alert(message);
|
||||
console.log(' htdflBdstUpdate ')
|
||||
resetHtdflTableIndex(0);
|
||||
};
|
||||
@@ -97,7 +100,8 @@ export default function HtdflRegForm({
|
||||
const onDelete = async () => {
|
||||
const code = htdflForm.ctpvCd ? htdflForm.ctpvCd : htdflForm.sggCd ? htdflForm.sggCd : "noCd";
|
||||
if (await confirm(`정말 ${htdflForm.bdstNm} 시설을 삭제하시겠습니까?`)) {
|
||||
await htdflBdstDelete(htdflForm, code);
|
||||
const message = await htdflBdstDelete(htdflForm, code);
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
handleMinusNumberChange,
|
||||
} from "@/components/lib/func/common";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { useAlertStore } from "@/src/shared/lib";
|
||||
import { DatePicker, FormUi } from "@common/business_components";
|
||||
import { Form, FormField, SelectBox } from "@common/business_components/ui";
|
||||
import { Button, Input } from "@common/components/ui";
|
||||
@@ -20,7 +21,6 @@ import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import BdstReg from "../bdstReg/bdstReg";
|
||||
import toast from "react-hot-toast";
|
||||
import BdstAdd from "../bdstReg/bdstAdd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { numSize, txtSize } from "@/app/store/common/code/basicCode";
|
||||
@@ -49,6 +49,7 @@ export default function RainRegForm({
|
||||
});
|
||||
const { t } = useTranslation('base');
|
||||
const { confirm } = useConfirm();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctYn] = form.watch([
|
||||
"reuseBuilding.0.grntchBdstCertYn",
|
||||
@@ -135,7 +136,7 @@ export default function RainRegForm({
|
||||
const myUUID = await getMyUUID();
|
||||
|
||||
if (!myUUID) {
|
||||
toast.error(t('noUserInfoMsg'));
|
||||
alert(t('noUserInfoMsg'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,11 +144,12 @@ export default function RainRegForm({
|
||||
const data = regCtpvCd ? regCtpvCd : regSggcd ? regSggcd : "noCd";
|
||||
|
||||
if (data === "noCd") {
|
||||
toast.error("시도/시군구 코드를 선택해야합니다.");
|
||||
alert("시도/시군구 코드를 선택해야합니다.");
|
||||
return;
|
||||
}
|
||||
const handleConfirm = async () => {
|
||||
rainBdstReg(values, data,myUUID);
|
||||
const message = await rainBdstReg(values, data,myUUID);
|
||||
alert(message);
|
||||
if (setIsModal) setIsModal(false);
|
||||
};
|
||||
if (await confirm(t("isInsertMsg"))) {
|
||||
@@ -155,7 +157,8 @@ export default function RainRegForm({
|
||||
}
|
||||
} else {
|
||||
const handleConfirm = async () => {
|
||||
await rainBdstUpdate(values, laeSeCd,myUUID);
|
||||
const message = await rainBdstUpdate(values, laeSeCd,myUUID);
|
||||
alert(message);
|
||||
resetRainTableIndex(0)
|
||||
};
|
||||
if (await confirm(t("isUpdateMsg"))) {
|
||||
@@ -167,7 +170,8 @@ export default function RainRegForm({
|
||||
const onDelete = async () => {
|
||||
const code = rainForm.ctpvCd ? rainForm.ctpvCd : rainForm.sggCd ? rainForm.sggCd : "noCd";
|
||||
if (await confirm(`정말 ${rainForm.bdstNm} 시설을 삭제하시겠습니까?`)) {
|
||||
await rainBdstDelete(rainForm, code);
|
||||
const message = await rainBdstDelete(rainForm, code);
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import BdstAdd from "../bdstReg/bdstAdd";
|
||||
import BdstReg from "../bdstReg/bdstReg";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { numSize, txtSize } from "@/app/store/common/code/basicCode";
|
||||
import toast from "react-hot-toast";
|
||||
import { useAlertStore } from "@/src/shared/lib";
|
||||
|
||||
export default function RswtrRegForm({
|
||||
rswtForm,
|
||||
@@ -53,6 +53,7 @@ export default function RswtrRegForm({
|
||||
// const defaultValues: z.infer<typeof rswtZod> = rswtZod.parse({});
|
||||
const { t } = useTranslation("base");
|
||||
const { confirm } = useConfirm();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const form = useForm<z.infer<typeof rswtZod>>({
|
||||
resolver: zodResolver(rswtZod),
|
||||
@@ -73,17 +74,18 @@ export default function RswtrRegForm({
|
||||
const myUUID = await getMyUUID();
|
||||
|
||||
if (!myUUID) {
|
||||
toast.error(t('noUserInfoMsg'));
|
||||
alert(t('noUserInfoMsg'));
|
||||
return;
|
||||
}
|
||||
if (isModal) {
|
||||
const data = regCtpvCd ? regCtpvCd : regSggcd ? regSggcd : "noCd";
|
||||
if (data === "noCd") {
|
||||
toast.error("시도/시군구 코드를 선택해야합니다.");
|
||||
alert("시도/시군구 코드를 선택해야합니다.");
|
||||
return;
|
||||
}
|
||||
const handleConfirm = async () => {
|
||||
rswtBdstReg(values, data,myUUID);
|
||||
const message = await rswtBdstReg(values, data,myUUID);
|
||||
alert(message);
|
||||
if (setIsModal) setIsModal(false);
|
||||
};
|
||||
if (await confirm(t("isInsertMsg"))) {
|
||||
@@ -91,7 +93,8 @@ export default function RswtrRegForm({
|
||||
}
|
||||
} else {
|
||||
const handleConfirm = async () => {
|
||||
rswtBdstUpdate(values, laeSeCd,myUUID);
|
||||
const message = await rswtBdstUpdate(values, laeSeCd,myUUID);
|
||||
alert(message);
|
||||
resetRswtTableIndex(0)
|
||||
};
|
||||
if (await confirm(t("isUpdateMsg"))) {
|
||||
@@ -103,7 +106,8 @@ export default function RswtrRegForm({
|
||||
const onDelete = async () => {
|
||||
const code = rswtForm.ctpvCd ? rswtForm.ctpvCd : rswtForm.sggCd ? rswtForm.sggCd : "noCd";
|
||||
if (await confirm(`정말 ${rswtForm.bdstNm} 시설을 삭제하시겠습니까?`)) {
|
||||
await rswtBdstDelete(rswtForm, code);
|
||||
const message = await rswtBdstDelete(rswtForm, code);
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
rswtExcelDataCheck,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel";
|
||||
import { showConfirmToast } from "@/components/lib/func/common";
|
||||
import { useAlertStore } from "@/src/shared/lib";
|
||||
import {
|
||||
filePicked,
|
||||
filePickedArray,
|
||||
@@ -23,7 +24,6 @@ import { Button, Input } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function ChkgdExcel({
|
||||
@@ -46,6 +46,7 @@ export default function ChkgdExcel({
|
||||
} = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const [excelData, setExcelData] = useState<
|
||||
rswtChkZodType[] | rainChkZodType[]
|
||||
>();
|
||||
@@ -89,7 +90,7 @@ export default function ChkgdExcel({
|
||||
useEffect(() => {
|
||||
if (file) {
|
||||
if (form.getValues("chckYr").length < 1) {
|
||||
toast.error("파일업로드 이전에 등록년도를 작성해주세요 ");
|
||||
alert("파일업로드 이전에 등록년도를 작성해주세요 ");
|
||||
setFile(null);
|
||||
return;
|
||||
}
|
||||
@@ -102,6 +103,9 @@ export default function ChkgdExcel({
|
||||
res,
|
||||
form.getValues("chckYr")
|
||||
);
|
||||
if (excelData.message) {
|
||||
alert(excelData.message);
|
||||
}
|
||||
if (excelData.issues && excelData.issues.length > 0) {
|
||||
excelData.issues.some((err, index) => {
|
||||
showConfirmToast(err);
|
||||
@@ -190,33 +194,35 @@ export default function ChkgdExcel({
|
||||
// );
|
||||
// }
|
||||
|
||||
const onSubmit = (values: z.infer<typeof chkgdRegExcel>) => {
|
||||
const onSubmit = async (values: z.infer<typeof chkgdRegExcel>) => {
|
||||
if (values.chckYr === "") {
|
||||
toast.error("등록년도를 작성해주세요");
|
||||
alert("등록년도를 작성해주세요");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === "RNB") {
|
||||
if (excelData === undefined || excelData?.length === 0) {
|
||||
toast.error("빈 파일 및 파일 오류 입니다.");
|
||||
alert("빈 파일 및 파일 오류 입니다.");
|
||||
|
||||
return;
|
||||
} else {
|
||||
rainChkExcelDataUPload(
|
||||
const message = await rainChkExcelDataUPload(
|
||||
excelData as rainChkZodType[],
|
||||
form.getValues("chckYr"),
|
||||
laeSeCd
|
||||
);
|
||||
alert(message);
|
||||
setIsRegExcel(false);
|
||||
setYearChange(form.getValues("chckYr"));
|
||||
}
|
||||
} else if (type === "RST") {
|
||||
if (excelRswtData === undefined || excelRswtData?.length === 0) {
|
||||
toast.error("빈 파일 및 파일 오류 입니다.");
|
||||
alert("빈 파일 및 파일 오류 입니다.");
|
||||
|
||||
return;
|
||||
} else {
|
||||
rswtChkExceDataUpload(excelRswtData as rswtChkZodType[], laeSeCd);
|
||||
const message = await rswtChkExceDataUpload(excelRswtData as rswtChkZodType[], laeSeCd);
|
||||
alert(message);
|
||||
setIsRegExcel(false);
|
||||
setYearChange(form.getValues("chckYr"));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgd
|
||||
import type { rswtrPolutionsZode } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList";
|
||||
import { codeToText } from "@/components/lib/func/common";
|
||||
import { GuideDetailsTable } from "@/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable";
|
||||
import { useAlertStore } from "@/src/shared/lib";
|
||||
import { ScrollArea, Title } from "@common/business_components/ui";
|
||||
import { Button } from "@common/components/ui";
|
||||
import React, { useEffect, useState } from "react";
|
||||
@@ -28,6 +29,7 @@ export default function ChkgdModal({
|
||||
rainChkGuidUpdate,
|
||||
rwstPolAndGuideUpdate,
|
||||
} = useWrStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const [guidData, setGuidData] = useState<splRuseWaterType[]>();
|
||||
const [headList, setHeadList] = useState<{
|
||||
splHeadList: TableUpperProps[];
|
||||
@@ -206,7 +208,7 @@ export default function ChkgdModal({
|
||||
}
|
||||
};
|
||||
|
||||
const allDataUpdate = () => {
|
||||
const allDataUpdate = async () => {
|
||||
const realGuideDetail = obj.guideDetails;
|
||||
|
||||
if (updateData === undefined || updateData.length === 0) return;
|
||||
@@ -233,14 +235,16 @@ export default function ChkgdModal({
|
||||
});
|
||||
obj.guideDetails = realGuideDetail;
|
||||
if (type === "RNB") {
|
||||
rainChkGuidUpdate(obj);
|
||||
const message = await rainChkGuidUpdate(obj);
|
||||
alert(message);
|
||||
setIsModal(false);
|
||||
} else {
|
||||
const polution = Object.values(upPolutionData)
|
||||
.flat()
|
||||
.filter((item) => item.utztnUsgCd !== "평균");
|
||||
obj.rswtrPollutions = polution;
|
||||
rwstPolAndGuideUpdate([obj]);
|
||||
const message = await rwstPolAndGuideUpdate([obj]);
|
||||
alert(message);
|
||||
setIsModal(false);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user