wr: message alert matMng

This commit is contained in:
2026-03-18 14:46:36 +09:00
parent 3d11a8be21
commit 59e3dd0804
7 changed files with 59 additions and 41 deletions
@@ -9,12 +9,14 @@ import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/b
import { ContentsDiv, DateMonthPicker, downloadExcel, SearchDiv, SearchFormLeft, SearchFormRight, SelectBox, UiModal, UiTable, type SelectDataType } from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div";
import { Button, Label, ScrollArea } from "@common/components/ui";
import { useAlertStore } from "@/src/shared/lib";
import { useEffect, useState, useRef } from "react";
import { toast, Toaster } from "react-hot-toast";
import { Toaster } from "react-hot-toast";
export default function DrgtSttn() {
const { code, drgt, drgtSearch, drgtModalSearch, drgtInit } = useWrStore((state) => state);
const { drgtRes, drgtMoRes } = drgt;
const alert = useAlertStore((state) => state.setMessage);
const [fromDate, setFromDate] = useState<string>('202506');
const [toDate, setToDate] = useState<string>('202506');
const [selectSgg, setSelectSgg] = useState<SelectDataType[]>([{ val: '0', text: '전체' }]);
@@ -32,7 +34,7 @@ export default function DrgtSttn() {
if (fromDate && toDate && drgtRes[index]) {
drgtModalSearch(fromDate, toDate, drgtRes[index].sggNm ?? '');
} else {
toast.error("조회기간을 선택해주세요.");
alert("조회기간을 선택해주세요.");
}
}
@@ -27,8 +27,9 @@ import {
} from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div";
import { Button } from "@common/components/ui";
import { useAlertStore } from "@/src/shared/lib";
import { useCallback, useEffect, useState } from "react";
import toast, { Toaster } from "react-hot-toast";
import { Toaster } from "react-hot-toast";
import { useTranslation } from "react-i18next";
export default function LdrmntCoSttn() {
@@ -46,6 +47,7 @@ export default function LdrmntCoSttn() {
const [resetPage, isResetPage] = useState(false);
const [isDownloadClicked, setIsDownloadClicked] = useState(false);
const { t } = useTranslation('base');
const alert = useAlertStore((state) => state.setMessage);
const { regAuthrtYn, mdfcnAuthrtYn } = auth;
const excelClick = useCallback(() => {
@@ -113,7 +115,7 @@ export default function LdrmntCoSttn() {
headerRange: "A1:F1"
});
} else {
toast.error(t('excelDownErrMsg'));
alert(t('excelDownErrMsg'));
}
setIsDownloadClicked(false);
}, [excelData, isDownloadClicked]);
@@ -270,7 +272,8 @@ export default function LdrmntCoSttn() {
readonly={mdfcnAuthrtYn === 'N'}
onFormSubmit={async (value) => {
const handleConfirm = async () => {
await ldrmntUpdate(value);
const message = await ldrmntUpdate(value);
alert(message);
setDetailModal({ ...detailModal, isOpen: false });
ldrmntSearch(false, pageNation, '20', computeCityNm(), searchTxt || "");
};
+11 -14
View File
@@ -1,5 +1,4 @@
import { fetchType, getFetchWithCount, putFectch } from "@/components/lib/api";
import toast from "react-hot-toast";
import type { CommonTableProps } from "../../common/type/header";
import {
constCostHeadListExport,
@@ -50,7 +49,7 @@ type coRvwActions = {
splyCd: string,
dmdCd: string,
data: DedMatUpdateType
) => void;
) => Promise<string>;
coMatRvwSearch: (
pageNo: number,
pageCnt: number,
@@ -104,20 +103,17 @@ export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => {
splyCd: string,
dmdCd: string,
data: DedMatUpdateType
) => {
): Promise<string> => {
try {
const response = await putFectch(
`/reuseFc/request/cst/${splyCd}/${dmdCd}`,
data
);
if (response.status === 200) {
if(data.flg ==='Sub'){
toast.success("매칭 검토로 저장되었습니다.");
}else{
toast.success("매칭 검토완료로 저장되었습니다.");
}
const successMessage =
data.flg === "Sub"
? "매칭 검토로 저장되었습니다."
: "매칭 검토완료로 저장되었습니다.";
const coMatRvwRes = await coMatInit(
1,
@@ -125,21 +121,22 @@ export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => {
new Date().getFullYear().toString(),
new Date().getFullYear().toString()
);
return set((state: coRvwState) => ({
set((state: coRvwState) => ({
...state,
coRvw: {
...state.coRvw,
coMatRvwRes: coMatRvwRes.data,
coMatRvwCount:coMatRvwRes.count,
coMatRvwCount: coMatRvwRes.count,
init: false,
},
}));
return successMessage;
} else {
toast.error("매칭 검토 저장에 실패했습니다.");
return "매칭 검토 저장에 실패했습니다.";
}
} catch (e) {
toast.error("매칭 검토 저장 오류입니다.");
console.error("coMatRvwUpdate error", e);
return "매칭 검토 저장 오류입니다.";
}
},
coMatRvwSearch: async (
@@ -1,6 +1,5 @@
import type { CommonTableProps } from "@/app/store/common/type/header";
import { deleteFectch, fetchType, getFetchWithCount, postFectch, putFectch } from "@/components/lib/api";
import toast from "react-hot-toast";
import { z } from "zod";
import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
import { ldrmntHeadListExport, ldrmntNodeListExport, ldrmntZod } from "./headList";
@@ -35,7 +34,7 @@ type ldrmntActions = {
ldrmntRegData: (data: any[]) => void,
ldrmntInit: (isExcel: boolean, con: string) => void
ldrmntSearch: (isExcel: boolean, page: number, sggCd: string, total: string, coNm: string) => void;
ldrmntUpdate: (ldrmntRes: customLdrmnt) => void;
ldrmntUpdate: (ldrmntRes: customLdrmnt) => Promise<string>;
ldrmntDelete: () => void;
loadingOpen: (isOpen: boolean) => void
};
@@ -192,12 +191,14 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
);
if (res.ok) {
toast.success("잠재수요처 상세정보가 수정되었습니다.",)
return "잠재수요처 상세정보가 수정되었습니다.";
}
return "잠재수요처 상세정보 수정에 실패하였습니다.";
} catch (error) {
console.error("Error ldrmntUpdate:", error);
toast.error("잠재수요처 상세정보 수정에 실패하였습니다.")
return "잠재수요처 상세정보 수정에 실패하였습니다.";
}
return "잠재수요처 상세정보가 없습니다.";
},
ldrmntDelete: async () => {
try {
@@ -228,4 +229,4 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
}
},
}
}
}
@@ -1,5 +1,4 @@
import { fetchType, getFetchWithCount, postFectch } from "@/components/lib/api";
import { toast } from "react-hot-toast";
import type { TableUpperProps } from "../../common/type/header";
import { ruseCaseHeadListExport } from "./headList";
import type { ruseCaseMngExcelProps } from "./excel";
@@ -24,7 +23,7 @@ type ruseCaseActions = {
usageCd: string,
name: string
) => Promise<void>;
insertRuseCaseMng: (data: any) => Promise<void>;
insertRuseCaseMng: (data: any) => Promise<string>;
};
const fetchSearchRuseCaseMng = async (
@@ -131,11 +130,10 @@ export const ruseCaseActionsExport: (set: any) => ruseCaseActions = (
}
},
insertRuseCaseMng: async (data: any) => {
insertRuseCaseMng: async (data: any): Promise<string> => {
try {
const response = await fetchInsertRuseCaseMng(data);
if (response.status === 200) {
toast.success("물재이용사례 등록이 완료되었습니다. ");
const res = await getFetchWithCount(
fetchType.WR,
`/reuseFc/pubFcRuseCase/1/10/0/0`
@@ -147,11 +145,13 @@ export const ruseCaseActionsExport: (set: any) => ruseCaseActions = (
count: res.count,
},
}));
return "물재이용사례 등록이 완료되었습니다.";
} else {
return "물재이용사례 등록에 실패했습니다.";
}
} catch (e) {
console.log(e);
toast.error("물재이용사례 등록에 실패하였습니다. ");
return "물재이용사례 등록에 실패했습니다.";
}
},
};
@@ -13,6 +13,7 @@ import {
getInterpolation,
transformAndInterpolate,
} from "@/components/lib/func/calculateConstCost ";
import { useAlertStore } from "@/src/shared/lib";
import { ConstCostFeeTable } from "@/components/ui/modal/coMat/constCostFeeTable";
import { RateFeeTableModal } from "@/components/ui/modal/coMat/rateFeeModal";
import {
@@ -53,6 +54,7 @@ export default function ConCostForm({
getRateFee,
getConstCostFee,
} = useWrStore((state) => state);
const alert = useAlertStore((state) => state.setMessage);
const ref = useRef<boolean>(false);
@@ -108,11 +110,11 @@ export default function ConCostForm({
const calculateConstCost = useCallback(() => {
const usgPrcsProcs = usgPrcsProcsWatch;
if (!dmndQtyWatch) {
toast.error("요구수량(m³/일)을 확인해주세요 계산할수 없습니다. ");
alert("요구수량(m³/일)을 확인해주세요 계산할수 없습니다. ");
return;
}
if (usgPrcsProcs === null || usgPrcsProcs === undefined) {
toast.error(
alert(
"용도에 따른 처리공정을 확인할수 없습니다. 용도를 확인해주세요. "
);
return;
@@ -175,9 +177,9 @@ export default function ConCostForm({
form.setValue("totalConstCost", Math.round(realResult));
}
}, [constCostRes, rateFeeRes, usgPrcsProcsWatch, dmndQtyWatch]);
const onSubmit = (value: DmdCoReqType) => {
const onSubmit = async (value: DmdCoReqType) => {
if (value.demandCst && !value.demandCst.prcsFcltCpctCstrnCst) {
toast.error("공사비 계산 진행 후 저장을 눌러주새요");
alert("공사비 계산 진행 후 저장을 눌러주새요");
return;
}
@@ -211,10 +213,15 @@ export default function ConCostForm({
<div className="flex gap-2 mt-2">
<Button
size="sm"
onClick={() => {
onClick={async () => {
toast.dismiss(t.id);
coMatRvwUpdate(pk, form.getValues("dmdInfoId"), data);
const message = await coMatRvwUpdate(
pk,
form.getValues("dmdInfoId"),
data
);
alert(message);
}}
>
확인
@@ -226,10 +233,15 @@ export default function ConCostForm({
</span>
));
} else {
coMatRvwUpdate(pk, form.getValues("dmdInfoId"), data);
const message = await coMatRvwUpdate(
pk,
form.getValues("dmdInfoId"),
data
);
alert(message);
}
}else{
toast.error('후보지를 먼저 선택해주세요')
alert('후보지를 먼저 선택해주세요')
}
}
} else if (type === "hist") {
@@ -2,6 +2,7 @@ import { useWrStore } from "@/app/store";
import { coRegExcel } from "@/app/store/matDmd/coSttn/headList";
import { mapAndValidateRow, type ruseCaseMngExcelProps } from "@/app/store/matDmd/ruseCaseMng/excel";
import { showConfirmToast } from "@/components/lib/func/commom";
import { useAlertStore } from "@/src/shared/lib";
import { filePicked, Title } from "@common/business_components/ui";
import { Form } from "@common/business_components/ui/form";
import { Button, Input } from "@common/components/ui";
@@ -12,6 +13,7 @@ import type { z } from "zod";
export default function RuseCaseMngExcel({setIsExcelOpen}:{setIsExcelOpen: (isOpen:boolean)=>void}) {
const { insertRuseCaseMng } = useWrStore((state) => state);
const alert = useAlertStore((state) => state.setMessage);
const form = useForm<z.infer<typeof coRegExcel>>({
resolver: zodResolver(coRegExcel),
});
@@ -20,7 +22,7 @@ export default function RuseCaseMngExcel({setIsExcelOpen}:{setIsExcelOpen: (isOp
const onSubmit = () => {
if (file) {
filePicked(file, 0).then((res: unknown) => {
filePicked(file, 0).then(async (res: unknown) => {
try {
const newArray: ruseCaseMngExcelProps[] = []
const isError:string[][] = []
@@ -144,7 +146,8 @@ export default function RuseCaseMngExcel({setIsExcelOpen}:{setIsExcelOpen: (isOp
alert("업로드할 데이터가 없습니다.");
return;
}else if(newArray.length > 0){
insertRuseCaseMng(newArray);
const message = await insertRuseCaseMng(newArray);
alert(message);
setIsExcelOpen(false);
}
} catch (e) {
@@ -188,4 +191,4 @@ export default function RuseCaseMngExcel({setIsExcelOpen}:{setIsExcelOpen: (isOp
</div>
</>
);
}
}