wr: message alert

This commit is contained in:
2026-03-18 13:20:32 +09:00
parent c57c7ce1f7
commit 3d11a8be21
7 changed files with 51 additions and 38 deletions
@@ -1,5 +1,11 @@
"use client"; "use client";
/**
* 📄 CoMatRvw 수요매칭 검토
* Next.js App Router (app/) 기반 페이지 컴포넌트 예시
*
* - 대민에서 신청하는 수요처의 수요등록 정보를 운영담당자가 수요 매칭 검토를 진행한다.
* - 전체적으로 form을 만들어서 form안에 데이터를 넣고 api를 호출하여 저장한다.
*/
import { useWrStore } from "@/app/store"; import { useWrStore } from "@/app/store";
import { btnClass } from "@/app/store/common/code"; import { btnClass } from "@/app/store/common/code";
import { usageProcData } from "@/app/store/matDmd/coMatRvw/headList"; import { usageProcData } from "@/app/store/matDmd/coMatRvw/headList";
@@ -33,26 +39,21 @@ import {
} from "@common/business_components/ui"; } from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div"; import ListDiv from "@common/business_components/ui/list_div";
import { Button, Input, Label } from "@common/components/ui"; import { Button, Input, Label } from "@common/components/ui";
import { useAlertStore } from "@/src/shared/lib";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import moment from "moment"; import moment from "moment";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useForm, useWatch } from "react-hook-form"; import { useForm, useWatch } from "react-hook-form";
import toast, { Toaster } from "react-hot-toast"; import { Toaster } from "react-hot-toast";
import { z } from "zod"; import { z } from "zod";
/**
* 📄 CoMatRvw 수요매칭 검토
* Next.js App Router (app/) 기반 페이지 컴포넌트 예시
*
* - 대민에서 신청하는 수요처의 수요등록 정보를 운영담당자가 수요 매칭 검토를 진행한다.
* - 전체적으로 form을 만들어서 form안에 데이터를 넣고 api를 호출하여 저장한다.
*/
export default function CoMatRvw() { export default function CoMatRvw() {
const { auth, code, coRvw, coMatRvwInit, coMatRvwSearch, coMatRvwInqua } = const { auth, code, coRvw, coMatRvwInit, coMatRvwSearch, coMatRvwInqua } =
useWrStore((state) => state); useWrStore((state) => state);
const { coMatRvwRes, coMatRvwCount } = coRvw; const { coMatRvwRes, coMatRvwCount } = coRvw;
const { regAuthrtYn } = auth; const { regAuthrtYn } = auth;
const alert = useAlertStore((state) => state.setMessage);
//init, sub, match //init, sub, match
const initRef = useRef<boolean>(false); const initRef = useRef<boolean>(false);
@@ -253,7 +254,7 @@ export default function CoMatRvw() {
const fromNum = Number(fromDate); const fromNum = Number(fromDate);
const toNum = Number(toDate); const toNum = Number(toDate);
if (fromNum > toNum) { if (fromNum > toNum) {
toast.error( alert(
"시작년도가 종료년도 이후로 설정할 수 없습니다." "시작년도가 종료년도 이후로 설정할 수 없습니다."
); );
} else { } else {
@@ -21,8 +21,9 @@ import {
} from "@common/business_components/ui"; } from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div"; import ListDiv from "@common/business_components/ui/list_div";
import { Button, Label } from "@common/components/ui"; import { Button, Label } from "@common/components/ui";
import { useAlertStore } from "@/src/shared/lib";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import toast, { Toaster } from "react-hot-toast"; import { Toaster } from "react-hot-toast";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import * as XLSX from "xlsx"; import * as XLSX from "xlsx";
@@ -44,6 +45,7 @@ export default function RuseCaseMng() {
const [name, setName] = useState<string>(""); const [name, setName] = useState<string>("");
const [resetPage, isResetPage] = useState(false); const [resetPage, isResetPage] = useState(false);
const { t } = useTranslation("base"); const { t } = useTranslation("base");
const alert = useAlertStore((state) => state.setMessage);
// 엑셀 등록 모달 // 엑셀 등록 모달
const [isExcelOpen, setIsExcelOpen] = useState<boolean>(false); const [isExcelOpen, setIsExcelOpen] = useState<boolean>(false);
@@ -84,7 +86,7 @@ export default function RuseCaseMng() {
if (!excelList) return; if (!excelList) return;
if (excelList.length === 0) { if (excelList.length === 0) {
toast.error(t("excelDownErrMsg")); alert(t("excelDownErrMsg"));
return; return;
} }
fetch(`/sample_ruseCaseMng.xlsx`, {}).then(async (response) => { fetch(`/sample_ruseCaseMng.xlsx`, {}).then(async (response) => {
@@ -24,9 +24,10 @@ import {
} from "@common/business_components/ui"; } from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div"; import ListDiv from "@common/business_components/ui/list_div";
import { Button, Label } from "@common/components/ui"; import { Button, Label } from "@common/components/ui";
import { useAlertStore } from "@/src/shared/lib";
import moment from "moment"; import moment from "moment";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import toast, { Toaster } from "react-hot-toast"; import { Toaster } from "react-hot-toast";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
export default function RuseRvwHstry() { export default function RuseRvwHstry() {
const { const {
@@ -40,6 +41,7 @@ export default function RuseRvwHstry() {
} = useWrStore((state) => state); } = useWrStore((state) => state);
const { rvwHistRes, ruseHistHeadList, rvwHistCount } = ruseHist; const { rvwHistRes, ruseHistHeadList, rvwHistCount } = ruseHist;
const { regAuthrtYn } = auth; const { regAuthrtYn } = auth;
const alert = useAlertStore((state) => state.setMessage);
const [pageNation, setPageNatiion] = useState<number>(1); const [pageNation, setPageNatiion] = useState<number>(1);
@@ -79,7 +81,7 @@ export default function RuseRvwHstry() {
const fromNum = Number(fromDate); const fromNum = Number(fromDate);
const toNum = Number(toDate); const toNum = Number(toDate);
if (fromNum > toNum) { if (fromNum > toNum) {
toast.error("시작년도가 종료년도 이후로 설정할 수 없습니다."); alert("시작년도가 종료년도 이후로 설정할 수 없습니다.");
} else { } else {
let con: string | number = ""; let con: string | number = "";
if (String(objSearch.city).length > 0) { if (String(objSearch.city).length > 0) {
@@ -133,7 +135,7 @@ export default function RuseRvwHstry() {
selectedData[index]?.splyFcltFlg === "매칭완료" && selectedData[index]?.splyFcltFlg === "매칭완료" &&
headId === "completeYn" headId === "completeYn"
) { ) {
toast.error(t("canNotChangeMatStateMsg")); alert(t("canNotChangeMatStateMsg"));
return; return;
} }
} }
@@ -177,7 +179,7 @@ export default function RuseRvwHstry() {
// </span> // </span>
// )); // ));
} else { } else {
toast.error( t('isNotMatchFinishMsg')); alert(t('isNotMatchFinishMsg'));
} }
}; };
useEffect(() => { useEffect(() => {
@@ -327,7 +327,8 @@ export default function CoSttn() {
? objSearch.sgg ? objSearch.sgg
: objSearch.city; : objSearch.city;
if (updateData?.dmdInfoId) { if (updateData?.dmdInfoId) {
await updateDemandCompany(data as DemandCompType); const message = await updateDemandCompany(data as DemandCompType);
alert(message);
coSttnInit("1", "13", String(con)); coSttnInit("1", "13", String(con));
setIsDmdModal({ setIsDmdModal({
isMoal: false, isMoal: false,
@@ -343,7 +344,8 @@ export default function CoSttn() {
alert(`사업자번호 ${dmd.dmdInfoId}는 이미 등록되었습니다. 다시등록해주세요`); alert(`사업자번호 ${dmd.dmdInfoId}는 이미 등록되었습니다. 다시등록해주세요`);
return; return;
} }
await regDemandCompany(data as DemandCompType); const message = await regDemandCompany(data as DemandCompType);
alert(message);
coSttnInit("1", "13", String(con)); coSttnInit("1", "13", String(con));
setIsDmdModal({ setIsDmdModal({
isMoal: false, isMoal: false,
@@ -44,13 +44,14 @@ import {
import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm";
import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm";
import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal"; import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal";
import toast, { Toaster } from "react-hot-toast"; // toast 이미 import 되어 있음 import { Toaster } from "react-hot-toast";
import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg"; import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg";
import { useFieldArray, useForm, type FieldErrors } from "react-hook-form"; // FieldErrors 타입 추가 import { useFieldArray, useForm, type FieldErrors } from "react-hook-form"; // FieldErrors 타입 추가
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod"; import { z } from "zod";
import { createDefaultPbnstItem } from "./utilsZod"; import { createDefaultPbnstItem } from "./utilsZod";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useAlertStore } from "@/src/shared/lib";
export default function PublicReuseFaciltyInsert() { export default function PublicReuseFaciltyInsert() {
const { const {
auth, auth,
@@ -66,6 +67,7 @@ export default function PublicReuseFaciltyInsert() {
} = useWrStore((state) => state); } = useWrStore((state) => state);
const { t } = useTranslation("base"); const { t } = useTranslation("base");
const alert = useAlertStore((state) => state.setMessage);
const { pubFacHeadList, pbnstHasuResCount, pbnstHasuRes, pbnstRes } = pbnst; const { pubFacHeadList, pbnstHasuResCount, pbnstHasuRes, pbnstRes } = pbnst;
const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth; const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth;
const [, setCurrentTab] = useState<string>("mng"); const [, setCurrentTab] = useState<string>("mng");
@@ -140,7 +142,7 @@ export default function PublicReuseFaciltyInsert() {
const isFcltSuccess = resFclt.status === "fulfilled"; const isFcltSuccess = resFclt.status === "fulfilled";
const isBizSuccess = resBiz.status === "fulfilled"; const isBizSuccess = resBiz.status === "fulfilled";
if (isFcltSuccess && isBizSuccess) { if (isFcltSuccess && isBizSuccess) {
toast.success("하수 재이용 시설 및 사업이 수정되었습니다. "); alert("하수 재이용 시설 및 사업이 수정되었습니다.");
// 메시지 표시, 페이지 이동 등 // 메시지 표시, 페이지 이동 등
} else { } else {
let message = ""; let message = "";
@@ -151,7 +153,7 @@ export default function PublicReuseFaciltyInsert() {
if (!isBizSuccess) { if (!isBizSuccess) {
message += "하수재이용 시설 사업 "; message += "하수재이용 시설 사업 ";
} }
toast.error(message + "오류 입니다 "); alert(message + "오류 입니다 ");
pubHasuInit("1", laeSeCd); pubHasuInit("1", laeSeCd);
} }
}); });
@@ -215,7 +217,7 @@ export default function PublicReuseFaciltyInsert() {
} }
} }
// 최종 오류 메시지 출력 // 최종 오류 메시지 출력
toast.error(`${prefix}${message}`); alert(`${prefix}${message}`);
}); });
} }
}; };
@@ -321,8 +323,8 @@ export default function PublicReuseFaciltyInsert() {
onClick={() => { onClick={() => {
// pbnstMngData([] as customPbnst[]); // pbnstMngData([] as customPbnst[]);
if (!selectRow) { if (!selectRow) {
toast.error( alert(
"하수리시시설을 테이블을 선택하고 등록버튼을 눌러주세요" "재시용시설을 등록할 하수리시시설을 테이블에서 선택하고 등록버튼을 눌러주세요"
); );
return; return;
} else { } else {
@@ -416,7 +418,7 @@ export default function PublicReuseFaciltyInsert() {
onClick={() => { onClick={() => {
// pbnstMngData([] as customPbnst[]); // pbnstMngData([] as customPbnst[]);
if (!selectRow) { if (!selectRow) {
toast.error( alert(
"하수리시시설을 테이블을 선택하고 등록버튼을 눌러주세요" "하수리시시설을 테이블을 선택하고 등록버튼을 눌러주세요"
); );
return; return;
+10 -9
View File
@@ -7,7 +7,6 @@ import {
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form"; import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
import type { conCostFeeType, rateFeeType } from "./type"; import type { conCostFeeType, rateFeeType } from "./type";
import toast from "react-hot-toast";
export const comFcltStateExport: comFcltState = { export const comFcltStateExport: comFcltState = {
@@ -59,8 +58,8 @@ export type comFcltState = {
type comFcltActions = { type comFcltActions = {
getSwtrmtFcltNm: (searchNm: string) => void; getSwtrmtFcltNm: (searchNm: string) => void;
getDemandCompList: (searchNm: string, cnt: number) => void; getDemandCompList: (searchNm: string, cnt: number) => void;
regDemandCompany: (data: DemandCompType) => void; regDemandCompany: (data: DemandCompType) => Promise<string>;
updateDemandCompany: (data: DemandCompType) => void; updateDemandCompany: (data: DemandCompType) => Promise<string>;
getConstCostFee: (year: string) => void; getConstCostFee: (year: string) => void;
getRateFee: (year: string) => void; getRateFee: (year: string) => void;
}; };
@@ -109,7 +108,6 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
fetchType.WR fetchType.WR
); );
if (response.status === 200) { if (response.status === 200) {
toast.success('수요처가 등록되었습니다. ')
set((state: comFcltState) => { set((state: comFcltState) => {
return { return {
@@ -117,11 +115,12 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
dmdIsSucees: "success" dmdIsSucees: "success"
} }
}); });
return "수요처가 등록되었습니다.";
} }
return "수요처 등록에 실패하였습니다.";
} catch (err) { } catch (err) {
console.log(err); console.log(err);
toast.error('수요처가 등록 오류입니다.. ') return "수요처 등록 중 오류가 발생했습니다.";
} }
}, },
updateDemandCompany: async (data: DemandCompType) => { updateDemandCompany: async (data: DemandCompType) => {
@@ -131,7 +130,6 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
let message = ""; let message = "";
if (response.status === 200) { if (response.status === 200) {
message = "success"; message = "success";
toast.success('수요처 정보가 변경되었습니다. ' )
} else { } else {
message = "fail"; message = "fail";
} }
@@ -142,10 +140,13 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
dmdIsSucees: message dmdIsSucees: message
} }
}); });
if (response.status === 200) {
return "수요처 정보가 변경되었습니다.";
}
return "수요처 정보 변경에 실패하였습니다.";
} catch (err) { } catch (err) {
console.log(err); console.log(err);
toast.success('수요처 정보가 오류입니다. ' ) return "수요처 정보 변경 중 오류가 발생했습니다.";
} }
}, },
getRateFee: async (year: string) => { getRateFee: async (year: string) => {
@@ -39,8 +39,9 @@ import type { DemandCompType } from "@common/business_components/ui/sdmInsertFor
import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm"; import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm";
import type { SelectDataType } from "@common/business_components"; import type { SelectDataType } from "@common/business_components";
import { BuseWaterQulity } from "./buseWaterQulity/buseWaterQulity"; import { BuseWaterQulity } from "./buseWaterQulity/buseWaterQulity";
import toast from "react-hot-toast"; // import toast from "react-hot-toast";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useAlertStore } from "@/src/shared/lib";
//import { useTranslation } from "react-i18next"; //import { useTranslation } from "react-i18next";
@@ -74,6 +75,7 @@ export function PbnstBuseForm({
readonly?: boolean; readonly?: boolean;
}) { }) {
const { t } = useTranslation("base"); const { t } = useTranslation("base");
const alert = useAlertStore((state) => state.setMessage);
const { const {
code, code,
@@ -193,7 +195,7 @@ export function PbnstBuseForm({
fcDemands: [], fcDemands: [],
}); });
await appendBiz(newItem); await appendBiz(newItem);
toast.success(t('insertRuseBiz',{cycle: pbnstBizCycle + 1})) alert(t('insertRuseBiz',{cycle: pbnstBizCycle + 1}))
setIndexBiz(pbnstBizCycle); setIndexBiz(pbnstBizCycle);
}, [form, indexMng, indexBiz, appendBiz, setIndexBiz]); }, [form, indexMng, indexBiz, appendBiz, setIndexBiz]);
@@ -779,8 +781,9 @@ export function PbnstBuseForm({
rtnValue={(searchText: string, pageCnt: number) => { rtnValue={(searchText: string, pageCnt: number) => {
getDemandCompList(searchText, pageCnt); getDemandCompList(searchText, pageCnt);
}} }}
rtnInputData={(data) => { rtnInputData={async (data) => {
regDemandCompany(data as DemandCompType); const message = await regDemandCompany(data as DemandCompType);
alert(message);
setIsDmdModal({ setIsDmdModal({
isMoal: false, isMoal: false,
data: data as DemandCompType, data: data as DemandCompType,