From ff78ef96f2158013264c3c795c0eeede5ada4e15 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 14 Jul 2025 17:33:27 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4=EC=9A=A9?= =?UTF-8?q?=20=EC=8B=9C=EC=84=A4=20=EB=93=B1=EB=A1=9D=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=ED=91=9C=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 78 ++++++++++--------- .../app/ruseFcltMng/fcltReg/rainReg/page.tsx | 4 - .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 41 +++++----- 3 files changed, 60 insertions(+), 63 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index a583efccf..fbdb90eb6 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -14,7 +14,7 @@ import { useWrStore } from "../../../store"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components"; import { useCallback, useEffect, useState } from "react"; import ListDiv from "@common/business_components/ui/list_div"; -import { tableData } from "@/components/lib/func/commom"; +import { confirmToast, tableData } from "@/components/lib/func/commom"; import type { customPbnst, fcBizType, @@ -34,6 +34,7 @@ import { useFieldArray, useForm, type FieldErrors } from "react-hook-form"; // F import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { createDefaultPbnstItem } from "./utilsZod"; +import { useTranslation } from "react-i18next"; export default function PublicReuseFaciltyInsert() { const { @@ -46,7 +47,8 @@ export default function PublicReuseFaciltyInsert() { pubHasuSearch, pbnstRuseBizUpdate, } = useWrStore((state) => state); - const { pubFacHeadList, pbnstHasuResCount,pbnstHasuRes, pbnstRes } = pbnst; + const { t } = useTranslation("base"); + const { pubFacHeadList, pbnstHasuResCount, pbnstHasuRes, pbnstRes } = pbnst; const [, setCurrentTab] = useState("mng"); const [isRuseReg, setIsRuseReg] = useState<{ isModal: boolean; @@ -108,28 +110,31 @@ export default function PublicReuseFaciltyInsert() { }; }); - Promise.allSettled([ - pbnstRuseFcltUpdate(pbnst as customPbnst[]), - pbnstRuseBizUpdate(bizs), - ]).then(([resFclt, resBiz]) => { - const isFcltSuccess = resFclt.status === "fulfilled"; - const isBizSuccess = resBiz.status === "fulfilled"; - if (isFcltSuccess && isBizSuccess) { - toast.success("하수 재이용 시설 및 사업이 수정되었습니다. "); - // 메시지 표시, 페이지 이동 등 - } else { - let message = ""; - // ✅ 각각 어떤 항목이 실패했는지도 로그/알림 처리 - if (!isFcltSuccess) { - message = "하수재이용 시설 "; + const handleConfirm = async () => { + Promise.allSettled([ + pbnstRuseFcltUpdate(pbnst as customPbnst[]), + pbnstRuseBizUpdate(bizs), + ]).then(([resFclt, resBiz]) => { + const isFcltSuccess = resFclt.status === "fulfilled"; + const isBizSuccess = resBiz.status === "fulfilled"; + if (isFcltSuccess && isBizSuccess) { + toast.success("하수 재이용 시설 및 사업이 수정되었습니다. "); + // 메시지 표시, 페이지 이동 등 + } else { + let message = ""; + // ✅ 각각 어떤 항목이 실패했는지도 로그/알림 처리 + if (!isFcltSuccess) { + message = "하수재이용 시설 "; + } + if (!isBizSuccess) { + message += "하수재이용 시설 사업 "; + } + toast.error(message + "오류 입니다 "); + pubHasuInit("1", "41"); } - if (!isBizSuccess) { - message += "하수재이용 시설 사업 "; - } - toast.error(message + "오류 입니다 "); - pubHasuInit("1", "41"); - } - }); + }); + }; + confirmToast(t("isUpdatetMsg"), handleConfirm); }; // 폼 유효성 검사 실패 시 호출될 함수 @@ -230,7 +235,6 @@ export default function PublicReuseFaciltyInsert() { useEffect(() => { if (pbnst.pbnstRes && pbnst.pbnstRes?.length > 0) { form.reset({ items: pbnst.pbnstRes }); - } else { form.reset({ items: [] }); } @@ -238,14 +242,16 @@ export default function PublicReuseFaciltyInsert() { const appendPbnstRuseFclt = useCallback(() => { if (pbnstRes && pbnstRes.length > 0) { - if (selectRow) { // pbnstRes.length를 사용하여 새로운 항목의 인덱스를 결정 - append(createDefaultPbnstItem(selectRow, pbnstRes.length)); + if (selectRow) { + // pbnstRes.length를 사용하여 새로운 항목의 인덱스를 결정 + append(createDefaultPbnstItem(selectRow, pbnstRes.length)); setIsRuseReg({ isModal: true }); } } else { - if (selectRow) { // pbnstRes가 비어있으면 첫 항목이므로 인덱스 0 + if (selectRow) { + // pbnstRes가 비어있으면 첫 항목이므로 인덱스 0 - append(createDefaultPbnstItem(selectRow, 0)); + append(createDefaultPbnstItem(selectRow, 0)); setIsRuseReg({ isModal: true }); } } @@ -277,14 +283,12 @@ export default function PublicReuseFaciltyInsert() { className="" size={"sm"} onClick={() => { - if(searchTxt && searchTxt?.length > 0) { - pubHasuSearch(String(pageNation), "41", searchTxt) - - }else{ - pubHasuInit(String(pageNation), "41"); - } - isResetPage(true); - + if (searchTxt && searchTxt?.length > 0) { + pubHasuSearch(String(pageNation), "41", searchTxt); + } else { + pubHasuInit(String(pageNation), "41"); + } + isResetPage(true); }} > 조회 @@ -322,7 +326,7 @@ export default function PublicReuseFaciltyInsert() { tableData={bdstTable || []} headlist={pubFacHeadList} pageSize={10} - total={pbnstHasuResCount||20} + total={pbnstHasuResCount || 20} headName={"공공 하수처리시설 목록"} cellClick={cellClick} onPageChange={setPageNation} diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx index a7895ff13..828129bf6 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx @@ -73,10 +73,6 @@ export default function Home() { }; - // const bdstChgModal = (chgBuilding: chgBuilding[]) => { - // setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding }); - // }; - useEffect(() => { getRainData(pageNation, "41"); }, [pageNation]); diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index 69ba1fb68..e068c6c91 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -15,42 +15,42 @@ import { } from "@common/components/ui"; import { useEffect, useState } from "react"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; -import { - type FieldErrors, - type UseFormReturn, -} from "react-hook-form"; +import { type FieldErrors, type UseFormReturn } from "react-hook-form"; import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg"; import type { z } from "zod"; +import { confirmToast } from "@/components/lib/func/commom"; +import { useTranslation } from "react-i18next"; export function PbnstRegModal({ form, setPbnstInsert, - onInvalid + onInvalid, }: { form: UseFormReturn<{ items: PbnstRegArrrayType }>; setPbnstInsert: (data: customPbnst) => void; - onInvalid:(errors: FieldErrors<{ items: z.infer[] }>) => void + onInvalid: ( + errors: FieldErrors<{ items: z.infer[] }> + ) => void; }) { - - // const [pbnstBdstForm, setPbnstBdstForm] = useState( - // {} as customPbnst - // ); + const { t } = useTranslation("base"); //TODO: 유즈 스테이트에 set만해도 되나? const [, setCurrentTab] = useState("mng"); - //const setCurrentTab = "mng" const [indexMng, setIndexMng] = useState(0); const [indexBiz, setIndexBiz] = useState(0); + const onSubmit = async (valuse: { items: PbnstRegArrrayType }) => { + const item = valuse.items[indexMng]; + const data = item ? writeRgtrAndMdfr([item]) : []; +// + const handleConfirm = () => { + if (data && data[0]) { + setPbnstInsert(data[0]); + } + }; + confirmToast(t("isInsertMsg"), handleConfirm); + }; - const onSubmit = async (valuse: { items: PbnstRegArrrayType }) => { - const item = valuse.items[indexMng]; - const data = item ? writeRgtrAndMdfr([item]) : []; - if (data && data[0]) { - setPbnstInsert(data[0]); - } - }; - const handleTabChange = (value: string) => { setCurrentTab(value); }; @@ -60,7 +60,6 @@ export function PbnstRegModal({ }, [form.formState.errors]); useEffect(() => { - const firstForm = form.getValues("items"); if (firstForm) { setIndexMng(firstForm.length - 1); @@ -94,7 +93,6 @@ export function PbnstRegModal({ @@ -106,7 +104,6 @@ export function PbnstRegModal({ indexBiz={indexBiz} setIndexBiz={setIndexBiz} formType={"reg"} - // firstBizData={pbnstBdstForm.fcBizs} />