diff --git a/apps/wr/app/(with-layout)/matMng/coMat/coMatRvw/page.tsx b/apps/wr/app/(with-layout)/matMng/coMat/coMatRvw/page.tsx index d48c24960..0551b07a2 100644 --- a/apps/wr/app/(with-layout)/matMng/coMat/coMatRvw/page.tsx +++ b/apps/wr/app/(with-layout)/matMng/coMat/coMatRvw/page.tsx @@ -1,5 +1,11 @@ "use client"; - +/** + * πŸ“„ CoMatRvw μˆ˜μš”λ§€μΉ­ κ²€ν†  + * Next.js App Router (app/) 기반 νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈ μ˜ˆμ‹œ + * + * - λŒ€λ―Όμ—μ„œ μ‹ μ²­ν•˜λŠ” μˆ˜μš”μ²˜μ˜ μˆ˜μš”λ“±λ‘ 정보λ₯Ό μš΄μ˜λ‹΄λ‹Ήμžκ°€ μˆ˜μš” λ§€μΉ­ κ²€ν† λ₯Ό μ§„ν–‰ν•œλ‹€. + * - μ „μ²΄μ μœΌλ‘œ form을 λ§Œλ“€μ–΄μ„œ formμ•ˆμ— 데이터λ₯Ό λ„£κ³  apiλ₯Ό ν˜ΈμΆœν•˜μ—¬ μ €μž₯ν•œλ‹€. + */ import { useWrStore } from "@/app/store"; import { btnClass } from "@/app/store/common/code"; import { usageProcData } from "@/app/store/matDmd/coMatRvw/headList"; @@ -33,26 +39,21 @@ import { } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, Input, Label } from "@common/components/ui"; +import { useAlertStore } from "@/src/shared/lib"; import { zodResolver } from "@hookform/resolvers/zod"; import moment from "moment"; import { useEffect, useRef, useState } from "react"; import { useForm, useWatch } from "react-hook-form"; -import toast, { Toaster } from "react-hot-toast"; +import { Toaster } from "react-hot-toast"; import { z } from "zod"; -/** - * πŸ“„ CoMatRvw μˆ˜μš”λ§€μΉ­ κ²€ν†  - * Next.js App Router (app/) 기반 νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈ μ˜ˆμ‹œ - * - * - λŒ€λ―Όμ—μ„œ μ‹ μ²­ν•˜λŠ” μˆ˜μš”μ²˜μ˜ μˆ˜μš”λ“±λ‘ 정보λ₯Ό μš΄μ˜λ‹΄λ‹Ήμžκ°€ μˆ˜μš” λ§€μΉ­ κ²€ν† λ₯Ό μ§„ν–‰ν•œλ‹€. - * - μ „μ²΄μ μœΌλ‘œ form을 λ§Œλ“€μ–΄μ„œ formμ•ˆμ— 데이터λ₯Ό λ„£κ³  apiλ₯Ό ν˜ΈμΆœν•˜μ—¬ μ €μž₯ν•œλ‹€. - */ export default function CoMatRvw() { const { auth, code, coRvw, coMatRvwInit, coMatRvwSearch, coMatRvwInqua } = useWrStore((state) => state); const { coMatRvwRes, coMatRvwCount } = coRvw; const { regAuthrtYn } = auth; + const alert = useAlertStore((state) => state.setMessage); //init, sub, match const initRef = useRef(false); @@ -253,7 +254,7 @@ export default function CoMatRvw() { const fromNum = Number(fromDate); const toNum = Number(toDate); if (fromNum > toNum) { - toast.error( + alert( "μ‹œμž‘λ…„λ„κ°€ μ’…λ£Œλ…„λ„ μ΄ν›„λ‘œ μ„€μ •ν•  수 μ—†μŠ΅λ‹ˆλ‹€." ); } else { diff --git a/apps/wr/app/(with-layout)/matMng/coMat/ruseCaseMng/page.tsx b/apps/wr/app/(with-layout)/matMng/coMat/ruseCaseMng/page.tsx index d76549153..d315b2c25 100644 --- a/apps/wr/app/(with-layout)/matMng/coMat/ruseCaseMng/page.tsx +++ b/apps/wr/app/(with-layout)/matMng/coMat/ruseCaseMng/page.tsx @@ -21,8 +21,9 @@ import { } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, Label } from "@common/components/ui"; +import { useAlertStore } from "@/src/shared/lib"; import { useEffect, useState } from "react"; -import toast, { Toaster } from "react-hot-toast"; +import { Toaster } from "react-hot-toast"; import { useTranslation } from "react-i18next"; import * as XLSX from "xlsx"; @@ -44,6 +45,7 @@ export default function RuseCaseMng() { const [name, setName] = useState(""); const [resetPage, isResetPage] = useState(false); const { t } = useTranslation("base"); + const alert = useAlertStore((state) => state.setMessage); // μ—‘μ…€ 등둝 λͺ¨λ‹¬ const [isExcelOpen, setIsExcelOpen] = useState(false); @@ -84,7 +86,7 @@ export default function RuseCaseMng() { if (!excelList) return; if (excelList.length === 0) { - toast.error(t("excelDownErrMsg")); + alert(t("excelDownErrMsg")); return; } fetch(`/sample_ruseCaseMng.xlsx`, {}).then(async (response) => { diff --git a/apps/wr/app/(with-layout)/matMng/coMat/ruseRvwHstry/page.tsx b/apps/wr/app/(with-layout)/matMng/coMat/ruseRvwHstry/page.tsx index 9b7737236..782becca9 100644 --- a/apps/wr/app/(with-layout)/matMng/coMat/ruseRvwHstry/page.tsx +++ b/apps/wr/app/(with-layout)/matMng/coMat/ruseRvwHstry/page.tsx @@ -24,9 +24,10 @@ import { } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, Label } from "@common/components/ui"; +import { useAlertStore } from "@/src/shared/lib"; import moment from "moment"; 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 RuseRvwHstry() { const { @@ -40,6 +41,7 @@ export default function RuseRvwHstry() { } = useWrStore((state) => state); const { rvwHistRes, ruseHistHeadList, rvwHistCount } = ruseHist; const { regAuthrtYn } = auth; + const alert = useAlertStore((state) => state.setMessage); const [pageNation, setPageNatiion] = useState(1); @@ -79,7 +81,7 @@ export default function RuseRvwHstry() { const fromNum = Number(fromDate); const toNum = Number(toDate); if (fromNum > toNum) { - toast.error("μ‹œμž‘λ…„λ„κ°€ μ’…λ£Œλ…„λ„ μ΄ν›„λ‘œ μ„€μ •ν•  수 μ—†μŠ΅λ‹ˆλ‹€."); + alert("μ‹œμž‘λ…„λ„κ°€ μ’…λ£Œλ…„λ„ μ΄ν›„λ‘œ μ„€μ •ν•  수 μ—†μŠ΅λ‹ˆλ‹€."); } else { let con: string | number = ""; if (String(objSearch.city).length > 0) { @@ -133,7 +135,7 @@ export default function RuseRvwHstry() { selectedData[index]?.splyFcltFlg === "λ§€μΉ­μ™„λ£Œ" && headId === "completeYn" ) { - toast.error(t("canNotChangeMatStateMsg")); + alert(t("canNotChangeMatStateMsg")); return; } } @@ -177,7 +179,7 @@ export default function RuseRvwHstry() { // // )); } else { - toast.error( t('isNotMatchFinishMsg')); + alert(t('isNotMatchFinishMsg')); } }; useEffect(() => { diff --git a/apps/wr/app/(with-layout)/matMng/coMng/coSttn/page.tsx b/apps/wr/app/(with-layout)/matMng/coMng/coSttn/page.tsx index f5fcf7d91..85d9ef635 100644 --- a/apps/wr/app/(with-layout)/matMng/coMng/coSttn/page.tsx +++ b/apps/wr/app/(with-layout)/matMng/coMng/coSttn/page.tsx @@ -327,7 +327,8 @@ export default function CoSttn() { ? objSearch.sgg : objSearch.city; if (updateData?.dmdInfoId) { - await updateDemandCompany(data as DemandCompType); + const message = await updateDemandCompany(data as DemandCompType); + alert(message); coSttnInit("1", "13", String(con)); setIsDmdModal({ isMoal: false, @@ -343,7 +344,8 @@ export default function CoSttn() { alert(`μ‚¬μ—…μžλ²ˆν˜Έ ${dmd.dmdInfoId}λŠ” 이미 λ“±λ‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€. λ‹€μ‹œλ“±λ‘ν•΄μ£Όμ„Έμš”`); return; } - await regDemandCompany(data as DemandCompType); + const message = await regDemandCompany(data as DemandCompType); + alert(message); coSttnInit("1", "13", String(con)); setIsDmdModal({ isMoal: false, diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 396edb8f0..9ad16e84d 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -44,13 +44,14 @@ import { import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; 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 { useFieldArray, useForm, type FieldErrors } from "react-hook-form"; // FieldErrors νƒ€μž… μΆ”κ°€ import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { createDefaultPbnstItem } from "./utilsZod"; import { useTranslation } from "react-i18next"; +import { useAlertStore } from "@/src/shared/lib"; export default function PublicReuseFaciltyInsert() { const { auth, @@ -66,6 +67,7 @@ export default function PublicReuseFaciltyInsert() { } = useWrStore((state) => state); const { t } = useTranslation("base"); + const alert = useAlertStore((state) => state.setMessage); const { pubFacHeadList, pbnstHasuResCount, pbnstHasuRes, pbnstRes } = pbnst; const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth; const [, setCurrentTab] = useState("mng"); @@ -140,7 +142,7 @@ export default function PublicReuseFaciltyInsert() { const isFcltSuccess = resFclt.status === "fulfilled"; const isBizSuccess = resBiz.status === "fulfilled"; if (isFcltSuccess && isBizSuccess) { - toast.success("ν•˜μˆ˜ 재이용 μ‹œμ„€ 및 사업이 μˆ˜μ •λ˜μ—ˆμŠ΅λ‹ˆλ‹€. "); + alert("ν•˜μˆ˜ 재이용 μ‹œμ„€ 및 사업이 μˆ˜μ •λ˜μ—ˆμŠ΅λ‹ˆλ‹€."); // λ©”μ‹œμ§€ ν‘œμ‹œ, νŽ˜μ΄μ§€ 이동 λ“± } else { let message = ""; @@ -151,7 +153,7 @@ export default function PublicReuseFaciltyInsert() { if (!isBizSuccess) { message += "ν•˜μˆ˜μž¬μ΄μš© μ‹œμ„€ 사업 "; } - toast.error(message + "였λ₯˜ μž…λ‹ˆλ‹€ "); + alert(message + "였λ₯˜ μž…λ‹ˆλ‹€ "); 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={() => { // pbnstMngData([] as customPbnst[]); if (!selectRow) { - toast.error( - "ν•˜μˆ˜λ¦¬μ‹œμ‹œμ„€μ„ ν…Œμ΄λΈ”μ„ μ„ νƒν•˜κ³  λ“±λ‘λ²„νŠΌμ„ λˆŒλŸ¬μ£Όμ„Έμš”" + alert( + "μž¬μ‹œμš©μ‹œμ„€μ„ 등둝할 ν•˜μˆ˜λ¦¬μ‹œμ‹œμ„€μ„ ν…Œμ΄λΈ”μ—μ„œ μ„ νƒν•˜κ³  λ“±λ‘λ²„νŠΌμ„ λˆŒλŸ¬μ£Όμ„Έμš”" ); return; } else { @@ -416,7 +418,7 @@ export default function PublicReuseFaciltyInsert() { onClick={() => { // pbnstMngData([] as customPbnst[]); if (!selectRow) { - toast.error( + alert( "ν•˜μˆ˜λ¦¬μ‹œμ‹œμ„€μ„ ν…Œμ΄λΈ”μ„ μ„ νƒν•˜κ³  λ“±λ‘λ²„νŠΌμ„ λˆŒλŸ¬μ£Όμ„Έμš”" ); return; diff --git a/apps/wr/app/store/common/searchCode/index.ts b/apps/wr/app/store/common/searchCode/index.ts index 03d1b0fc5..1478b10a8 100644 --- a/apps/wr/app/store/common/searchCode/index.ts +++ b/apps/wr/app/store/common/searchCode/index.ts @@ -7,7 +7,6 @@ import { import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form"; import type { conCostFeeType, rateFeeType } from "./type"; -import toast from "react-hot-toast"; export const comFcltStateExport: comFcltState = { @@ -59,8 +58,8 @@ export type comFcltState = { type comFcltActions = { getSwtrmtFcltNm: (searchNm: string) => void; getDemandCompList: (searchNm: string, cnt: number) => void; - regDemandCompany: (data: DemandCompType) => void; - updateDemandCompany: (data: DemandCompType) => void; + regDemandCompany: (data: DemandCompType) => Promise; + updateDemandCompany: (data: DemandCompType) => Promise; getConstCostFee: (year: string) => void; getRateFee: (year: string) => void; }; @@ -109,7 +108,6 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => { fetchType.WR ); if (response.status === 200) { - toast.success('μˆ˜μš”μ²˜κ°€ λ“±λ‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€. ') set((state: comFcltState) => { return { @@ -117,11 +115,12 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => { dmdIsSucees: "success" } }); + return "μˆ˜μš”μ²˜κ°€ λ“±λ‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€."; } + return "μˆ˜μš”μ²˜ 등둝에 μ‹€νŒ¨ν•˜μ˜€μŠ΅λ‹ˆλ‹€."; } catch (err) { console.log(err); - toast.error('μˆ˜μš”μ²˜κ°€ 등둝 였λ₯˜μž…λ‹ˆλ‹€.. ') - + return "μˆ˜μš”μ²˜ 등둝 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."; } }, updateDemandCompany: async (data: DemandCompType) => { @@ -131,7 +130,6 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => { let message = ""; if (response.status === 200) { message = "success"; - toast.success('μˆ˜μš”μ²˜ 정보가 λ³€κ²½λ˜μ—ˆμŠ΅λ‹ˆλ‹€. ' ) } else { message = "fail"; } @@ -142,10 +140,13 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => { dmdIsSucees: message } }); + if (response.status === 200) { + return "μˆ˜μš”μ²˜ 정보가 λ³€κ²½λ˜μ—ˆμŠ΅λ‹ˆλ‹€."; + } + return "μˆ˜μš”μ²˜ 정보 변경에 μ‹€νŒ¨ν•˜μ˜€μŠ΅λ‹ˆλ‹€."; } catch (err) { console.log(err); - toast.success('μˆ˜μš”μ²˜ 정보가 였λ₯˜μž…λ‹ˆλ‹€. ' ) - + return "μˆ˜μš”μ²˜ 정보 λ³€κ²½ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."; } }, getRateFee: async (year: string) => { diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 614a6a7a3..1fffe2cdb 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -39,8 +39,9 @@ import type { DemandCompType } from "@common/business_components/ui/sdmInsertFor import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm"; import type { SelectDataType } from "@common/business_components"; import { BuseWaterQulity } from "./buseWaterQulity/buseWaterQulity"; -import toast from "react-hot-toast"; +// import toast from "react-hot-toast"; import { useTranslation } from "react-i18next"; +import { useAlertStore } from "@/src/shared/lib"; //import { useTranslation } from "react-i18next"; @@ -74,6 +75,7 @@ export function PbnstBuseForm({ readonly?: boolean; }) { const { t } = useTranslation("base"); + const alert = useAlertStore((state) => state.setMessage); const { code, @@ -193,7 +195,7 @@ export function PbnstBuseForm({ fcDemands: [], }); await appendBiz(newItem); - toast.success(t('insertRuseBiz',{cycle: pbnstBizCycle + 1})) + alert(t('insertRuseBiz',{cycle: pbnstBizCycle + 1})) setIndexBiz(pbnstBizCycle); }, [form, indexMng, indexBiz, appendBiz, setIndexBiz]); @@ -779,8 +781,9 @@ export function PbnstBuseForm({ rtnValue={(searchText: string, pageCnt: number) => { getDemandCompList(searchText, pageCnt); }} - rtnInputData={(data) => { - regDemandCompany(data as DemandCompType); + rtnInputData={async (data) => { + const message = await regDemandCompany(data as DemandCompType); + alert(message); setIsDmdModal({ isMoal: false, data: data as DemandCompType,