diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index fa37a7704..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, 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={100000} + 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 83679a274..828129bf6 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx @@ -1,12 +1,10 @@ "use client"; import { useWrStore } from "@/app/store"; import { - type chgBuilding, type customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { tableData } from "@/components/lib/func/commom"; import RainRegForm from "@/components/ui/form/fcltReg/rainReg/rainRegForm"; -import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal"; import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; import { ContentsDiv, @@ -35,10 +33,6 @@ export default function Home() { const [pageNation, setPageNation] = useState(1); const [bdstTable, setbdstTable] = useState(); const [searchTxt, setSearchTxt] = useState(); - const [bdstChgProps, setBdstChgProps] = useState<{ - isOpen: boolean; - chgBuilding: chgBuilding[]; - }>({ isOpen: false, chgBuilding: [] }); useEffect(() => { setIsNewReg(false); @@ -60,7 +54,6 @@ export default function Home() { ...item, archArea: archArea, - bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N", }; } ); @@ -71,26 +64,13 @@ export default function Home() { } } }, [code, rainRes]); - const cellClick: (val: number | undefined, headId: string) => void = ( - val, - headId + const cellClick: (val: number | undefined) => void = ( + val ) => { if (val !== undefined) { setRainForm(rainRes[val]); } - if (headId === "bdstChgYn" && val !== undefined) { - if ( - rainRes[val]?.bdstInfoPk != null && - rainRes[val]?.chgBuilding.length > 0 - ) { - bdstChgModal(rainRes[val].chgBuilding); - } - } - }; - - const bdstChgModal = (chgBuilding: chgBuilding[]) => { - setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding }); }; useEffect(() => { @@ -149,8 +129,8 @@ export default function Home() { pageSize={20} total={rainResCount} headName={"건축물 목록"} - cellClick={(val, headId) => { - cellClick(val, headId); + cellClick={(val) => { + cellClick(val); }} onPageChange={setPageNation} > @@ -183,17 +163,6 @@ export default function Home() { }} /> - - } - onOpenChange={(open) => { - setBdstChgProps({ ...bdstChgProps, isOpen: open }); - }} - /> - diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx index 686154bc9..6945788c4 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx @@ -1,10 +1,8 @@ "use client"; import { useWrStore } from "@/app/store"; -import type { chgBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg"; import { tableData } from "@/components/lib/func/commom"; import RswtrRegForm from "@/components/ui/form/fcltReg/rswtrReg/rswtrRegForm"; -import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal"; import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; import { ContentsDiv, @@ -32,10 +30,6 @@ export default function Home() { const [pageNation, setPageNation] = useState(1); const [selectVal, setSelect] = useState(); const [bdstTable, setbdstTable] = useState(); - const [bdstChgProps, setBdstChgProps] = useState<{ - isOpen: boolean; - chgBuilding: chgBuilding[]; - }>({ isOpen: false, chgBuilding: [] }); const { rswtRes, rswtResCount } = rswt; useEffect(() => { if (!rswt.isInit) { @@ -77,28 +71,16 @@ export default function Home() { }, [rswtRes, selectVal]); const cellClick: (val: number | undefined, headId: string) => void = ( - val, - headId + val ) => { if ((bdstTable ?? []).length > 0 && val !== undefined) { { setSelect(val); - // setRswtForm(rswtRes[val]); } } - if (headId === "bdstChgYn" && val !== undefined) { - if ( - rswtRes[val]?.bdstInfoPk != null && - rswtRes[val]?.chgBuilding?.length > 0 - ) { - bdstChgModal(rswtRes[val].chgBuilding); - } - } - }; - const bdstChgModal = (chgBuilding: chgBuilding[]) => { - setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding }); }; + useEffect(() => { getRswtBdstData(pageNation, "41"); }, [pageNation]); @@ -184,16 +166,6 @@ export default function Home() { setIsNewReg(open); }} /> - - } - onOpenChange={(open) => { - setBdstChgProps({ ...bdstChgProps, isOpen: open }); - }} - /> diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx index 13d0cc974..be2f82319 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx @@ -1,17 +1,14 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ "use client"; import { useWrStore } from "@/app/store"; import { btnClass } from "@/app/store/common/code"; import type { - chgBuilding, customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { excelDownload, getCity, - tableData + tableData, } from "@/components/lib/func/commom"; -import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal"; import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal"; import SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal"; @@ -25,7 +22,7 @@ import { Title, UiModal, UiTable, - type SelectDataType + type SelectDataType, } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; @@ -43,24 +40,24 @@ export default function RainSttn() { const [pageNation, setPageNation] = useState(1); const [isChHead, setIsChHead] = useState(false); const [bdstTable, setBdstTable] = useState(); - const [selectSgg, setSelectSgg] = useState() + const [selectSgg, setSelectSgg] = useState(); const [resetPage, isResetPage] = useState(false); const isDownloadTriggered = useRef(false); - const [objSearch, setObjSearch] = useState({ sgg: "", city: "" }); - const [detailModal, setDetailModal] = useState<{ isOpen: boolean, data: customRainBdst | undefined }>({ data: undefined, isOpen: false }) - const [bdstChgProps, setBdstChgProps] = useState<{ + const [objSearch, setObjSearch] = useState({ + sgg: "", + city: "", + }); + const [detailModal, setDetailModal] = useState<{ isOpen: boolean; - chBuilding: chgBuilding[]; - }>({ isOpen: false, chBuilding: [] }); + data: customRainBdst | undefined; + }>({ data: undefined, isOpen: false }); + const [fcltNm, setFcltNm] = useState(""); - const { t } = useTranslation('base'); - const cellClick = (index: number | undefined, headId: string) => { - if (headId !== 'chBuildingYn' && index !== undefined && bdstTable !== undefined) { - setDetailModal({ isOpen: true, data: bdstTable[index] }) - } else if (headId === 'chBuildingYn' && index !== undefined && bdstTable !== undefined) { - if (bdstTable[index] && bdstTable[index]?.chgBuilding[0]?.bdstChgNm !== null) { - setBdstChgProps({ isOpen: true, chBuilding: bdstTable[index].chgBuilding }); - } + const { t } = useTranslation("base"); + + const cellClick = (index: number | undefined) => { + if (index !== undefined && bdstTable !== undefined) { + setDetailModal({ isOpen: true, data: bdstTable[index] }); } }; @@ -72,13 +69,14 @@ export default function RainSttn() { } else { const data = getCity(cityValue, code.sggCd); setSelectSgg(data); - const firstSggVal = data.find(item => item.val === "0")?.val || (data[0]?.val ?? ""); + const firstSggVal = + data.find((item) => item.val === "0")?.val || (data[0]?.val ?? ""); setObjSearch({ city: cityValue, sgg: firstSggVal }); } }; const getSgg = (val: string | number) => { - setObjSearch({ ...objSearch, sgg: String(val) }) + setObjSearch({ ...objSearch, sgg: String(val) }); }; const getConValue = () => { @@ -105,23 +103,29 @@ export default function RainSttn() { ...item, ...item.reuseBuilding[0], ...item.reuseBuilding[0].rainyObj, - dtfcltCpct: item.reuseBuilding[0].rainyObj.dtfcltCpct === -1 - ? "확인불가" - : item.reuseBuilding[0].rainyObj.dtfcltCpct, - instlCst: item.reuseBuilding[0].instlCst === -1 - ? "확인불가" - : item.reuseBuilding[0].instlCst, - instlCstSprtAmt: item.reuseBuilding[0].instlCstSprtAmt === -1 - ? "확인불가" - : item.reuseBuilding[0].instlCstSprtAmt, + dtfcltCpct: + item.reuseBuilding[0].rainyObj.dtfcltCpct === -1 + ? "확인불가" + : item.reuseBuilding[0].rainyObj.dtfcltCpct, + instlCst: + item.reuseBuilding[0].instlCst === -1 + ? "확인불가" + : item.reuseBuilding[0].instlCst, + instlCstSprtAmt: + item.reuseBuilding[0].instlCstSprtAmt === -1 + ? "확인불가" + : item.reuseBuilding[0].instlCstSprtAmt, chBuildingYn: item.chgBuilding[0]?.bdstChgNm !== null ? "Y" : "N", - pntfColArea: item.reuseBuilding[0].rainyObj.pntfColArea === -1 - ? "확인불가" - : item.reuseBuilding[0].rainyObj.pntfColArea, - filtrTrtmfctCpct: item.reuseBuilding[0].rainyObj.filtrTrtmfctCpct === -1 - ? "확인불가" - : item.reuseBuilding[0].rainyObj.filtrTrtmfctCpct, - archArea: Math.floor(item.archArea) === -1 ? "확인불가" : item.archArea, + pntfColArea: + item.reuseBuilding[0].rainyObj.pntfColArea === -1 + ? "확인불가" + : item.reuseBuilding[0].rainyObj.pntfColArea, + filtrTrtmfctCpct: + item.reuseBuilding[0].rainyObj.filtrTrtmfctCpct === -1 + ? "확인불가" + : item.reuseBuilding[0].rainyObj.filtrTrtmfctCpct, + archArea: + Math.floor(item.archArea) === -1 ? "확인불가" : item.archArea, }; }) .filter((item: any) => item.rainyObj !== undefined); @@ -129,8 +133,16 @@ export default function RainSttn() { }, [code, rainSttnRes]); useEffect(() => { - rainSttnSearch(false, pageNation, "20", String(getConValue()), fcltNm, code.cityCd, code.sggCd); - isResetPage(false) + rainSttnSearch( + false, + pageNation, + "20", + String(getConValue()), + fcltNm, + code.cityCd, + code.sggCd + ); + isResetPage(false); }, [pageNation]); useEffect(() => { @@ -145,15 +157,30 @@ export default function RainSttn() { "A1:W3" ); } else { - toast.error(t('excelDownErrMsg')); + toast.error(t("excelDownErrMsg")); } isDownloadTriggered.current = false; }, [rainSttn.excelList]); const excelClick = useCallback(() => { isDownloadTriggered.current = true; - rainSttnSearch(true, 1, String(rainSttnResCount), String(getConValue()), fcltNm, code.cityCd, code.sggCd); - }, [rainSttnSearch, objSearch, code.cityCd, code.sggCd, fcltNm, rainSttnResCount]); + rainSttnSearch( + true, + 1, + String(rainSttnResCount), + String(getConValue()), + fcltNm, + code.cityCd, + code.sggCd + ); + }, [ + rainSttnSearch, + objSearch, + code.cityCd, + code.sggCd, + fcltNm, + rainSttnResCount, + ]); return ( <> @@ -192,14 +219,21 @@ export default function RainSttn() { - +