Compare commits

...
Author SHA1 Message Date
leedj312 f731d0f9f0 변경사항 2025-07-21 19:04:13 +09:00
leedj312 069e489d03 온배수 현황 수질 작업중 2025-07-21 17:59:55 +09:00
leedj312 990dffc11c 물재이용 / 이동시 메인으로 이동 2025-07-21 17:59:38 +09:00
leedj312 ae97a48ba2 사이드바 매뉴이동 수정 2025-07-17 17:25:05 +09:00
leedj312 db70ba56c6 개발서버 env변경 2025-07-17 16:26:47 +09:00
leedj312 3fa1c526fe env 변경 2025-07-17 16:20:13 +09:00
leedj312 992893510e Merge remote-tracking branch 'origin/iipbs/wr/pfmncSttn' into iipbs/wr/dev 2025-07-17 16:05:11 +09:00
leedj312 5fe4bc94da Merge commit 'c22e07bc16afbc2888806b4e0d36606b8ea0d35f' into iipbs/wr/dev 2025-07-17 16:00:31 +09:00
leedj312 5f302a5711 로그인 테스트 작업중 2025-07-17 15:57:20 +09:00
jyha00 cc749c0c24 Merge remote-tracking branch 'origin/iipbs/common/main' into iipbs/wr/pfmncSttn 2025-07-17 13:16:56 +09:00
leedj312 bd6dfd31fd 엑셀 중수도 지도점검 데이터 확인 2025-07-16 19:27:24 +09:00
jyha00 5aaa55d0c9 수요매칭검토 기본사항 readonly 추가 2025-07-16 16:29:25 +09:00
jyha00 5a3ef19e5d 하수재이용실적 현황 검색조건 수정 2025-07-16 15:32:18 +09:00
jyha00 01cb48e5b6 하수재이용시설 등록 보증수질 input 변경, 신규등록 저장 버튼 위치 수정, 상단 고정 추가 2025-07-16 14:55:44 +09:00
leedj312 ea7536bea3 안쓰는 함수 제거 2025-07-16 13:58:19 +09:00
leedj312 2356c10d34 빗물지도점검 오류 검증 2025-07-16 13:43:03 +09:00
jyha00 8b2dd27a79 하수재이용시설 등록 저장 버튼 위치 변경 2025-07-16 13:37:57 +09:00
jyha00 079542cf74 Merge branch 'iipbs/common/main' into iipbs/wr/pfmncSttn 2025-07-16 13:20:32 +09:00
leedj312 35ff13fb38 헤드리스트 수정 중 2025-07-15 20:27:43 +09:00
leedj312 231c0c2940 Merge commit 'a92f567e5c624486d80984c5e4427543aafdfdde' into iipbs/wr/dev 2025-07-15 20:27:30 +09:00
jyha00 a92f567e5c 재이용실적 현황 페이지 오류 수정 2025-07-15 20:23:02 +09:00
leedj312 ff9d373fcd Merge commit 'c111c2c084cfe533453f568d17c9fa5bcba02797' into iipbs/wr/dev 2025-07-15 20:22:57 +09:00
leedj312 c111c2c084 서버설정 작업 완료 2025-07-15 20:22:31 +09:00
leedj312 2d5a08a271 안쓰는 코드 삭제 2025-07-15 17:16:37 +09:00
leedj312 9a8abee77c 빌드에러 수정 2025-07-15 16:52:42 +09:00
jyha00 4c30c2fa47 물재이용 페이지별 오류 수정 2025-07-15 15:40:55 +09:00
leedj312 0cca1c8dbe 빌드 확인필요 2025-07-15 15:39:32 +09:00
jyha00 def7b2b01c 지도점검 등록 및 현황 단위 추가, 용수명 가운데 정렬로 수정 2025-07-15 13:54:30 +09:00
jyha00 4891725f68 물재이용 페이지 단위 추가 2025-07-15 11:11:29 +09:00
58 changed files with 2339 additions and 745 deletions
+17 -1
View File
@@ -1,7 +1,23 @@
# NEXT_PUBLIC_SITE_ID = WR
# NEXT_PUBLIC_PORT = 11301
# NEXT_PUBLIC_PROXY_HOST = http://localhost:3001
# NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1
# NEXT_PUBLIC_FO_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1
# NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000
# NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload
# NEXT_PUBLIC_CLAIM_NAME = Authorization
# NEXT_PUBLIC_AUTH_USER_ID = token-id
# NEXT_PUBLIC_ACCESS_TOKEN = access-token
# NEXT_PUBLIC_REFRESH_TOKEN = refresh-token
NEXT_PUBLIC_SITE_ID = WR
NEXT_PUBLIC_PORT = 11301
NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11301
NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
# NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1
NEXT_PUBLIC_FO_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1
NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000
NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload
NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver
NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver
NEXT_PUBLIC_CLAIM_NAME = Authorization
+8 -3
View File
@@ -1,14 +1,19 @@
NEXT_PUBLIC_SITE_ID = WR
NEXT_PUBLIC_PORT = 3001
NEXT_PUBLIC_PROXY_HOST = http://localhost:3001
NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver
NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver
NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1
NEXT_PUBLIC_FO_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1
NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000
NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload
NEXT_PUBLIC_CLAIM_NAME = Authorization
NEXT_PUBLIC_AUTH_USER_ID = token-id
NEXT_PUBLIC_ACCESS_TOKEN = access-token
NEXT_PUBLIC_REFRESH_TOKEN = refresh-token
NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API
# NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.128:8883/sewerage-service/api # 최용성
#NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.66:8883/sewerage-service/api # 박이정
+20 -1
View File
@@ -1,7 +1,24 @@
# NEXT_PUBLIC_SITE_ID = WR
# NEXT_PUBLIC_PORT = 11301
# NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11301
# NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
# NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver
# NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver
# NEXT_PUBLIC_CLAIM_NAME = Authorization
# NEXT_PUBLIC_AUTH_USER_ID = token-id
# NEXT_PUBLIC_ACCESS_TOKEN = access-token
# NEXT_PUBLIC_REFRESH_TOKEN = refresh-token
NEXT_PUBLIC_SITE_ID = WR
NEXT_PUBLIC_PORT = 11301
NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11301
NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
# NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
NEXT_PUBLIC_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1
NEXT_PUBLIC_FO_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1
NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000
NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload
NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver
NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver
NEXT_PUBLIC_CLAIM_NAME = Authorization
@@ -10,3 +27,5 @@ NEXT_PUBLIC_ACCESS_TOKEN = access-token
NEXT_PUBLIC_REFRESH_TOKEN = refresh-token
NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API
+26
View File
@@ -0,0 +1,26 @@
"use client"
import { BaseLayout } from "@common/components/ui";
import { useWrStore } from "./store";
import { MainDiv } from "@common/business_components/ui";
import type { MenuItem } from "./store/common/type/menu";
export default function Base({
children,
changeMenu,
}: Readonly<{
children: React.ReactNode;
changeMenu: (path: string) => void;
}>) {
const { getMenuAuthrts } = useWrStore((state) => state);
return (
<BaseLayout
handleMenuClick={(e: MenuItem) => {
getMenuAuthrts(e.menuCd);
changeMenu(e.urlPath);
}}
>
<MainDiv>{children}</MainDiv>
</BaseLayout>
);
}
+21 -14
View File
@@ -1,11 +1,11 @@
'use client'
import { BaseLayout } from "@common/components";
"use client";
import "./globals.css";
import { StoreProvider } from "./store";
import { MainDiv } from "@common/business_components";
import koBase from '../public/locales/ko/message.json';
import { StoreProvider} from "./store";
import koBase from "../public/locales/ko/message.json";
import i18next from "i18next";
import { I18nextProvider } from "react-i18next";
import Base from "./base";
import { useRouter } from "next/navigation"; // ✅ App Router 전용
export default function RootLayout({
children,
@@ -13,28 +13,35 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
i18next.init({
lng: 'ko',
fallbackLng: 'ko',
lng: "ko",
fallbackLng: "ko",
resources: {
ko: {
base: koBase,
},
}
},
});
const router = useRouter();
const changeMenu = (path: string) => {
router.push(path);
};
return (
<html lang="en">
<body>
<I18nextProvider i18n={i18next}>
<StoreProvider>
<BaseLayout>
<MainDiv>
{children}
</MainDiv>
</BaseLayout>
<Base
changeMenu={changeMenu}
>
{children}
</Base>
</StoreProvider>
</I18nextProvider>
</body>
</html >
</html>
);
}
-5
View File
@@ -146,11 +146,6 @@ export default function Home() {
중수도시설통계
</Button>
</div>
<div className="col-span-2">
<Button className="w-full" onClick={() => {router.push('/stats/matStat')}}>
물재이용사례 관리
</Button>
</div>
</div>
</div>
@@ -316,8 +316,8 @@ export default function PublicReuseFaciltyInsert() {
</div>
</div>
<div className="grid grid-cols-6 gap-4 h-full">
<div className="col-span-4 h-full min-h-0">
<div className="grid grid-cols-8 gap-4 h-full">
<div className="col-span-5 h-full min-h-0">
<ListDiv className="min-h-0">
<ScrollArea className="h-[60vh]">
{" "}
@@ -335,24 +335,26 @@ export default function PublicReuseFaciltyInsert() {
</ScrollArea>
</ListDiv>
</div>
<ListDiv className="col-span-2 pr-6 ">
<ListDiv className="col-span-3 pr-6 ">
{formWatch && formWatch[0]?.pbnstRuseFcltId ? (
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
<TabsList className="">
<TabsTrigger className="!text-xl" value="mng">
시설정보
</TabsTrigger>
<TabsTrigger className="!text-xl" value="buse">
차수별정보
</TabsTrigger>
<div className="flex justify-between items-center">
<TabsList className="">
<TabsTrigger className="!text-xl" value="mng">
시설정보
</TabsTrigger>
<TabsTrigger className="!text-xl" value="buse">
차수별정보
</TabsTrigger>
</TabsList>
<Button
size={"sm"}
onClick={form.handleSubmit(onSubmit, onInvalid)}
className="!justify-end" // 저장 버튼 위치 조정
className="mr-5 mt-2"
>
저장
</Button>
</TabsList>
</div>
<ScrollArea className="h-[60vh]">
<TabsContent className="max-h-full" value="mng">
<PbnstMngForm
@@ -375,6 +377,7 @@ export default function PublicReuseFaciltyInsert() {
indexBiz={indexBiz}
/>
</TabsContent>
</ScrollArea>
</Tabs>
) : (
@@ -119,6 +119,9 @@ export default function PbnstSttn() {
selectUnitWaterShedData={code.lgbsnCd}
selectMiddleRegionData={code.mdmbsnCd}
selectEnvPartData={code.lclgvrnmntCd}
rightClassName="ml-auto mr-6 flex items-center space-x-1"
leftClassName="flex gap-5 w-9/12 m-4"
leftSelectClassName="w-1/4"
rightChildren={
<Button
className={btnClass}
@@ -141,11 +144,11 @@ export default function PbnstSttn() {
setSearchYear(String(val))
}
/>
<Label className="w-64 mt-2 mx-4 text-xl text-gray-600">
{"하수처리시설명 "}
<Label className="w-full mt-2 ml-4 text-xl text-gray-600">
{"하수처리시설명"}
</Label>
<SearchInput
className={"text-2xl w-full ㅍ"}
className={"text-2xl w-full"}
label=""
textValue={pbnRuseNm || ""}
setText={(e) => {
@@ -313,7 +313,7 @@ export default function PrfmncPrfmncReg() {
<ScrollArea className="h-[60vh]">
<div className="card-header">
<h3 className="text-2xl font-medium text-label">
{"하수처리수재이용 실적(m3) 등록결과"}
{"하수처리수재이용 실적(m³) 등록결과"}
</h3>
</div>
<Table variant="secondary">
@@ -5,13 +5,15 @@ import { btnClass } from "@/app/store/common/code";
import { initValInUsage, initValOutUsage, subTotalObj, totalObj, type FcPrfType, type PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
import { excelPrfmncSttnParsing } from "@/app/store/prfmncSttn/pbnstPrfmncSttn/excel";
import { excelDownload, yearOptions } from "@/components/lib/func/commom";
import { InputTableBody } from "@/components/lib/func/TableData";
import SearchInputText from "@/components/ui/searchInput/searchInput";
import { CHART_FORM, ContentsDiv, MainChart, SearchBaseForm, SelectBox, Title, UiTable, type ChartConfig, type ReturnType } from "@common/business_components";
import { CHART_FORM, ContentsDiv, MainChart, ScrollArea, SearchBaseForm, SelectBox, Title, UiTable, type ChartConfig, type ReturnType } from "@common/business_components";
import ListDiv from "@common/business_components/ui/list_div";
import { Label } from "@common/components/ui";
import { Label, Table, TableBody, TableHeader } from "@common/components/ui";
import { useCallback, useEffect, useRef, useState } from "react";
import toast, { Toaster } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import { headMakeprfmnc } from "../../prfmncReg/chkgdnReg/TableHead";
export default function PbnstPrfmncSttn() {
const {
@@ -88,11 +90,11 @@ export default function PbnstPrfmncSttn() {
const prfTableData = (prfList: PrfType[], year: string) => {
const inUsageData = structuredClone(initValInUsage).map(row => ({
...row
// 구분: "장내용수",
// 구분: "장내용수",
}));
const outUsageData = structuredClone(initValOutUsage).map(row => ({
...row
// 구분: "장외용수",
// 구분: "장외용수",
}));
const inSubtotal = { ...structuredClone(subTotalObj), 구분: "장내용수" };
const outSubtotal = { ...structuredClone(subTotalObj), 구분: "장외용수" };
@@ -505,7 +507,7 @@ export default function PbnstPrfmncSttn() {
useEffect(() => {
if (pbnRuseNm.length > 1)
pbnNmSearch("1", "23", ref.current, pbnRuseNm, searchYear,[]);
pbnNmSearch("1", "23", ref.current, pbnRuseNm, searchYear, []);
}, [pbnRuseNm]);
const cellClick = (index: number | undefined, headId: string) => {
@@ -528,19 +530,28 @@ export default function PbnstPrfmncSttn() {
selectMiddleRegionData={code.mdmbsnCd}
selectEnvPartData={code.lclgvrnmntCd}
rightChildren={undefined}
rightClassName="ml-auto mr-6 flex items-center space-x-1"
leftClassName="flex gap-5 w-9/12 m-4"
leftSelectClassName="w-1/6"
leftChildren={<div className="col-span-5">
<div className="flex flex-row">
<div className="flex flex-row items-center">
<Label className="text-xl text-gray-600">하수 재이용년도</Label>
{/* <div className="flex flex-row items-center"> */}
<div className="flex flex-row items-center gap-x-4 flex-nowrap">
{/* <Label className="w-full text-xl text-gray-600"> */}
<Label className="flex-none whitespace-nowrap text-xl text-gray-600">
하수 재이용년도</Label>
<SelectBox
className="h-full text-2xl"
// className="w-full h-full text-2xl mx-4"
className="flex-none w-32 h-full text-2xl"
label=""
selectClass={""}
selectArray={yearOptions}
value={fromDate}
onSelectValue={(val: string | number) => setFromDate(String(val))} />
<span> ~</span>
<SelectBox
className="h-full text-2xl"
// className="w-full h-full text-2xl mx-4"
className="flex-none w-32 h-full text-2xl mr-4"
label=""
selectClass={""}
selectArray={yearOptions}
@@ -554,7 +565,7 @@ export default function PbnstPrfmncSttn() {
setPbnRuseNm(searchNm || "");
}}
setRtnData={/*function (rtnData: any[]): void {setbdstTable(rtnData);}*/
()=>{}
() => { }
}
searchList={pbnstSttn.pbnstSearchData || []}
></SearchInputText>
@@ -575,7 +586,7 @@ export default function PbnstPrfmncSttn() {
if (fromNum > toNum) {
toast.error("시작년도가 종료년도 이후로 설정할 수 없습니다.");
} else {
if (toNum - fromNum > 5) {
if (toNum - fromNum > 4) {
toast.error("최대 5년까지 선택 가능합니다.");
} else {
tableHeadMaker(fromNum, toNum);
@@ -594,7 +605,7 @@ export default function PbnstPrfmncSttn() {
<div className="col-span-6">
<ListDiv>
<UiTable
headName={[]}
headName={undefined}
tableData={bdstTable || []}
headlist={pbnstPrfHeadList}
pageSize={20}
@@ -602,8 +613,7 @@ export default function PbnstPrfmncSttn() {
cellClick={(index: number | undefined, headId: string) => {
cellClick(index ?? undefined, headId);
}}
onPageChange={() => { }
}
onPageChange={() => { }}
index={0}
/>
@@ -611,47 +621,47 @@ export default function PbnstPrfmncSttn() {
<h3 className="mt-4 ml-2 text-2xl font-medium text-label">하수재이용실적 상세현황</h3>
<SelectBox
className="h-full w-1/12 text-2xl"
className="h-full w-1/12 text-2xl mt-2"
label=""
selectClass={""}
selectArray={selectYearList}
value={year}
onSelectValue={(val: string | number) => setYear(String(val))} />
<h1 className="">장내·외 용도별 하수재이용실적 현황(계)</h1>
<h1 className="my-2">장내·외 용도별 하수재이용실적 현황(계)</h1>
<div className="flex">
<div className="w-1/3">
<MainChart chartConfig={chartConfig} chartData={chartData} chartTitle={"장내·외 용수 총 실적"} chartForm={CHART_FORM.DN} />
<MainChart chartConfig={chartConfig} chartData={chartData} chartTitle={"장내·외 용수 총 실적(m³)"} chartForm={CHART_FORM.DN} />
</div>
<div className="w-1/3">
<MainChart chartConfig={dnInChartConfig} chartData={dnInUsage} chartTitle={"장내용수 실적"} chartForm={CHART_FORM.DN} />
<MainChart chartConfig={dnInChartConfig} chartData={dnInUsage} chartTitle={"장내용수 실적(m³)"} chartForm={CHART_FORM.DN} />
</div>
<div className="w-1/3">
<MainChart chartConfig={dnOutChartConfig} chartData={dnOutUsage} chartTitle={"장외용수 실적"} chartForm={CHART_FORM.DN} />
<MainChart chartConfig={dnOutChartConfig} chartData={dnOutUsage} chartTitle={"장외용수 실적(m³)"} chartForm={CHART_FORM.DN} />
</div>
</div>
<h1 className="">장내·외 월별 하수재이용실적 현황</h1>
<div className="flex">
<div className="w-1/3">
<MainChart chartConfig={barChartConfig} chartData={barData} chartTitle={"월별 장내·외 용수 총 실적"} chartForm={CHART_FORM.DOUBLEBAR} showLegend={true} />
<MainChart chartConfig={barChartConfig} chartData={barData} chartTitle={"월별 장내·외 용수 총 실적(m³)"} chartForm={CHART_FORM.DOUBLEBAR} showLegend={true} />
</div>
<div className="w-1/3">
<MainChart chartConfig={lnInChartConfig} chartData={inLineData} chartTitle={"월별 장내 용수 실적"} chartForm={CHART_FORM.LINE} />
<MainChart chartConfig={lnInChartConfig} chartData={inLineData} chartTitle={"월별 장내 용수 실적(m³)"} chartForm={CHART_FORM.LINE} />
</div>
<div className="w-1/3">
<MainChart chartConfig={lnOutChartConfig} chartData={outLineData} chartTitle={"월별 장외 용수 총 실적"} chartForm={CHART_FORM.LINE} />
<MainChart chartConfig={lnOutChartConfig} chartData={outLineData} chartTitle={"월별 장외 용수 총 실적(m³)"} chartForm={CHART_FORM.LINE} />
</div>
</div>
<h1 className="">하수재이용실적 현황</h1>
<ListDiv className="col-span-8 pr-6 ">
{/* <ScrollArea className="h-[60vh]"> */}
{/* <div className="card-header">
<h1 className="">하수재이용실적 현황 (단위: m³)</h1>
{/* <ListDiv className="col-span-8 pr-6 "> */}
{/* <ScrollArea className="h-[60vh]"> */}
{/* <div className="card-header">
<h3 className="text-2xl font-medium text-label">
{"하수처리수재이용 실적(m3) 등록결과"}
{"하수처리수재이용 실적(m³) 등록결과"}
</h3>
</div> */}
<UiTable
{/* <UiTable
headName={undefined}
tableData={prfData || []}
headlist={monthHeadList}
@@ -659,30 +669,31 @@ export default function PbnstPrfmncSttn() {
total={0}
cellClick={undefined}
onPageChange={()=>{}}>
</UiTable>
</UiTable> */}
{/* <ListDiv className="col-span-8 pr-6 ">
<ScrollArea className="h-[60vh]">
<div className="card-header">
<ListDiv className="col-span-8 pr-6 ">
<ScrollArea className={prfData && prfData.length > 0 ? "h-[60vh]" : ""}>
{/* <div className="card-header">
<h3 className="text-2xl font-medium text-label">
{"하수처리수재이용 실적(m3) 등록결과"}
{"하수재이용실적 현황 (단위: m³)"}
</h3>
</div>
</div> */}
<Table variant="secondary">
<TableHeader className="font-bold">
{headMakeprfmnc(monthHeadList, [])}
</TableHeader>
<TableBody>
{InputTableBody(prfData ?? [], monthHeadList, setPrfData)}
</TableBody>
</Table>
</ScrollArea>
</ListDiv> */}
{/* </ScrollArea> */}
<Table variant="secondary">
<TableHeader className="font-bold">
{headMakeprfmnc(monthHeadList, [])}
</TableHeader>
<TableBody>
{/* {InputTableBody(prfData ?? [], monthHeadList, setPrfData)} */}
{InputTableBody(prfData ?? [], monthHeadList, setPrfData, false)}
</TableBody>
</Table>
</ScrollArea>
</ListDiv>
{/* </ScrollArea> */}
</ListDiv>
{/* </ListDiv> */}
</div>
</div>
</ContentsDiv>
+75
View File
@@ -0,0 +1,75 @@
import { getFetch, getFetchWithCount } from "@/components/lib/api";
import toast from "react-hot-toast";
export const getMenuAuthrts = async (menuCd: number) => {
const response = await getFetch(
"LOCAL",
`/cms-service/api/v1/menu-authrts/pageinfo/${menuCd}`
);
authStateExport.auth = {
mngAuthrtYn: response[0].mngAuthrtYn,
inqAuthrtYn: response[0].mngAuthrtYn,
regAuthrtYn: response[0].mngAuthrtYn,
mdfcnAuthrtYn: response[0].mngAuthrtYn,
delAuthrtYn: response[0].mngAuthrtYn,
};
};
export type authState = {
auth: {
mngAuthrtYn: string;
inqAuthrtYn: string;
regAuthrtYn: string;
mdfcnAuthrtYn: string;
delAuthrtYn: string;
};
};
export type authType = authState & authActions;
export const authStateExport: authState = {
auth: {
mngAuthrtYn: "Y",
inqAuthrtYn: "Y",
regAuthrtYn: "Y",
mdfcnAuthrtYn: "Y",
delAuthrtYn: "Y",
},
};
export type authActions = {
getMenuAuthrts: (menuCd: number) => void;
};
export const authActionsExport: (set: any) => authActions = (set: any) => {
return {
getMenuAuthrts: async (menuCd: number) => {
try{
const response = await getFetchWithCount( 'LOCAL',
`/cms-service/api/v1/menu-authrts/pageinfo/${menuCd}`
);
set((state: authState) => {
return {
...state,
auth: {
mngAuthrtYn: response[0].mngAuthrtYn,
inqAuthrtYn: response[0].mngAuthrtYn,
regAuthrtYn: response[0].mngAuthrtYn,
mdfcnAuthrtYn: response[0].mngAuthrtYn,
delAuthrtYn: response[0].mngAuthrtYn,
},
};
});
}catch(e){
toast.error('권한 정보를 가져오는 중 오류가 발생했습니다. 관리자에게 문의하세요.');
console.error('Error fetching menu authorities:', e);
}
},
};
};
+32
View File
@@ -0,0 +1,32 @@
import { cmsPostFectch } from "@/components/lib/api";
export const isLogin = async () => {
const headers = {
accept: "application/json",
"Content-Type": "application/json",
"X-Site-Id": "WR",
"Access-Control-Expose-Headers" : ["Authorization","refresh-token","token-id"]
};
const param = { userId: "tuser10003", password: "test1234!" };
await cmsPostFectch("/user-service/login",param,headers);
};
// export type LoginState = {
// login: {} as any;
// };
// export type loginType = LoginState & LoginActions;
// export const loginState: LoginState = {
// login: {},
// };
// export type LoginActions = {
// isLogin: () => void;
// };
// export const loginActionExport: (set: any) => LoginActions = (set: any) => {
// return {
// isLogin: async () => {},
// };
// };
@@ -0,0 +1,19 @@
export interface MenuItem {
menuCd: number;
menuKornNm: string;
menuEngNm: string;
parentId: number | null;
sortSeq: number;
iconNm?: string;
children: MenuItem[] | null;
levelNo: number;
urlPath: string;
menuLnkgTypeCd: string;
menuLnkgSn: number;
menuPath: string;
qrcd: string;
useYn: string;
otptYn: string;
newWndwYn: string;
requiredUrlPath: boolean;
}
+7 -8
View File
@@ -35,13 +35,12 @@ export const drgtStateExport: drgtState = {
}
}
const initFetch = async (fromDate: string, toDate: string, sido:string[]) => {
console.log("sido",sido)
const initFetch = async (fromDate: string, toDate: string, sido: string[]) => {
const drgtData = await postFectch(
`/il/getDataCount/${fromDate}/${toDate}`,
sido,
fetchType.WR
);
`/il/getDataCount/${fromDate}/${toDate}`,
sido,
fetchType.WR
);
//주의, 관심, 정상 추출
const statusData = Array.from(
@@ -99,10 +98,10 @@ export const drgtActionsExport: (set: any) => drgtActions = (
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0');
const formatted = `${year}${month}`;
const fromDate = formatted;
const toDate = formatted;
//FIXME: 페이지 처음 로딩될때 데이터 보려고 6월로 박아놓음 이거 fromDate로 고치기
const drgtRes = await initFetch("202506", toDate, []);
const drgtRes = await initFetch(fromDate, toDate, []);
set((state: drgtState) => {
return {
...state,
@@ -1,6 +1,11 @@
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type { SelectDataType } from "@common/business_components";
import type { rainChkZodType } from ".";
import {
isInvalidDate,
isInvalidNumber,
parseRawValue,
} from "@/components/lib/func/excelFunc";
export const useTypes = [
"조경용수",
"청소화장실용수",
@@ -28,7 +33,7 @@ export type Buildingtype = {
export const buildingToExcelType = (
buildings: Buildingtype[],
sidoCode: SelectDataType[],
sggCdoe: SelectDataType[],
sggCdoe: SelectDataType[]
) => {
const excelData: string[][] = [];
buildings.forEach((building) => {
@@ -37,8 +42,8 @@ export const buildingToExcelType = (
building.bdstInfoSn.toString(),
sidoCode.find((sido) => sido.val === building.ctpvCd.toString())
?.text || "",
sggCdoe.find((sido) => sido.val === building.sggCd.toString())
?.text || "",
sggCdoe.find((sido) => sido.val === building.sggCd.toString())?.text ||
"",
building.daddr,
building.bdstNm,
"",
@@ -80,121 +85,125 @@ export const buildingToExcelType = (
});
});
return excelData;
};
export const excelToRainChkData = (excelData: any, year: string) => {
// const errors: string[] = [];
const rainChkgdData: rainChkZodType[] = excelData.map((item: any) => {
if (item["점검일"] !== undefined) {
const checkYmd = item["점검일"].replace(/\./g, "")
let vltnDt = item["과태료 부과일(위반일)"]
if (vltnDt !== undefined) {
vltnDt = vltnDt ? vltnDt.replace(/\./g, "") : "";
}
const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
let month = `${i + 1}`;
const splyData = item[`대체_${month}월`];
const ruseData = item[`빗물_${month}월`];
if (month.length < 2) month = "0" + month;
return {
utztnUsgCd: item["이용용도"],
ym: year + month,
chckYmd: checkYmd,
splyUswtrUtztnQnt: Number(splyData) || 0,
ruseFcltUtztnQnt: Number(ruseData) || 0,
flg: "RNB",
};
});
return {
bdstNm:item["시설명"] ?? "",
bdstRuseFcltSn: Number(item["NO"]),
chckYmd: checkYmd,
spwtPositn: item["유량측정방법"] ?? "",
rgtr: TEST_UUID,
oilqMeasMthd: item["운영관리형태"] ?? "",
anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
operMngCd: item["유량측정방법"] ?? "",
guideDetails: makeGuidDetail,
rainyDetails: [
{
utztnUsgCd: item["이용용도"] ?? "",
ph: Number(item["PH"] || 0),
trbt: Number(item["탁도"] || 0),
grssClfg: Number(item["총대장균군수"] || 0),
etc: item["기타"] || "", // 필드 누락 방지
vltnDt: vltnDt || "-",
vltnMttr: item["위반사항"] || "-",
levyAmt: Number(item["과태료부과금액(천원)"] || 0),
// const errors: string[] = [];
const issues: string[] = [];
const rainChkgdData: rainChkZodType[] = excelData
.map((item: any) => {
if (item["점검일"] !== undefined) {
const checkYmd = item["점검일"].replace(/\./g, "");
let vltnDt = item["과태료 부과일(위반일)"];
if (vltnDt !== undefined) {
vltnDt = vltnDt ? vltnDt.replace(/\./g, "") : "";
}
const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
let month = `${i + 1}`;
const splyData = parseRawValue(item[`대체_${month}월`]);
const ruseData = parseRawValue(item[`빗물_${month}월`]);
if (month.length < 2) month = "0" + month;
return {
utztnUsgCd: item["이용용도"],
ym: year + month,
chckYmd: checkYmd,
splyUswtrUtztnQnt: splyData,
ruseFcltUtztnQnt: ruseData,
flg: "RNB",
};
});
if (checkYmd.length > 7) {
return {
bdstNm: item["시설명"] ?? "",
bdstRuseFcltSn: Number(item["NO"]),
chckYmd: checkYmd,
spwtPositn: item["유량측정방법"] ?? "",
rgtr: TEST_UUID,
},
],
};
}
}).filter((el: any) => el !== undefined);
oilqMeasMthd: item["운영관리형태"] ?? "",
anlOperCst: parseRawValue(item["연간운영비(원/년)"]),
operMngCd: item["유량측정방법"] ?? "",
guideDetails: makeGuidDetail,
rainyDetails: [
{
utztnUsgCd: item["이용용도"],
trbt: parseRawValue(item["탁도"]),
grssClfg: parseRawValue(item["총대장균군수"]),
etc: item["기타"] || "", // 필드 누락 방지
vltnDt: vltnDt || "-",
vltnMttr: item["위반사항"] || "-",
levyAmt: parseRawValue(item["과태료부과금액(천원)"]),
rgtr: TEST_UUID,
},
],
};
}
}
})
.filter((el: any) => el !== undefined);
return rainChkgdData;
// // ✨ 오류 검사 - 가공된 데이터 기준
// const isInvalidNumber = (val: any) =>
// val !== undefined && val !== null && val !== "" && isNaN(Number(val));
if (rainChkgdData.length > 0) {
rainChkgdData.forEach((rain: any) => {
const defaultMessage = `[시설명: ${rain.bdstNm}, 점검일: ${rain.chckYmd}, 이용용도: ${rain.guideDetails[0]?.utztnUsgCd}] 항목에서 `;
// const isInvalidDate = (val: any) =>
// typeof val === "string" && !/^\d{4}\.\d{2}\.\d{2}$/.test(val.trim());
if (rain.chckYmd && isInvalidDate(rain.chckYmd)) {
issues.push(
defaultMessage + `점검일: 날짜 형식 아님 (${rain.chckYmd})`
);
}
if (rain.anlOperCst.length > 2 && isInvalidNumber(rain.anlOperCst)) {
issues.push(
defaultMessage +
` 연간운영비(원/년): 숫자 형식 아님 (${rain.anlOperCst})`
);
}
rain.rainyDetails?.forEach((key) => {
if (key.ph?.length > 1 && isInvalidNumber(key.ph)) {
issues.push(defaultMessage + `PH: 숫자 형식 아님 (${key.ph})`);
}
if (key.trbt?.length > 1 && isInvalidNumber(key.trbt)) {
issues.push(defaultMessage + `탁도: 숫자 형식 아님 (${key.trbt})`);
}
if (key.grssClfg?.length > 1 && isInvalidNumber(key.grssClfg)) {
issues.push(
defaultMessage + `총대장균군수: 숫자 형식 아님 (${key.grssClfg})`
);
}
if (key.levyAmt?.length > 1 && isInvalidNumber(key.levyAmt)) {
issues.push(
defaultMessage +
`과태료부과금액(천원): 숫자 형식 아님 (${key.levyAmt})`
);
}
if (key.vltnDt?.length > 2 && isInvalidDate(key.vltnDt)) {
issues.push(
defaultMessage +
`과태료 부과일(위반일): 날짜 형식 아님 (${key.vltnDt})`
);
}
});
rain.guideDetails?.forEach((guide) => {
const mm = guide.ym.substring(4);
if (isInvalidNumber(guide.splyUswtrUtztnQnt)) {
issues.push(
defaultMessage +
`대체_${mm}: 숫자 형식 아님 (${guide.splyUswtrUtztnQnt})`
);
}
if (isInvalidNumber(guide.ruseFcltUtztnQnt)) {
issues.push(
defaultMessage +
`빗물_${mm}: 숫자 형식 아님 (${guide.ruseFcltUtztnQnt})`
);
}
});
});
}
// const buildErrorMessage = (item: any, issues: string[]): string => {
// const 시설명 = item.bdstNm ?? "";
// const 점검일 = item.chckYmd ?? "";
// const 이용용도 = item.utztnUsgCd ?? "";
// return `시설명: ${시설명}, 점검일: ${점검일}, 이용용도: ${이용용도} (=> ${issues.join(", ")})`;
// };
if (issues.length > 0) {
return { rainChkgdData: [], issues };
}
// if (rainChkgdData.length > 0) {
// rainChkgdData.forEach((rain: any) => {
// const item = rain.__origin; // 원본 item
// const issues: string[] = [];
// if (rain.chckYmd && isInvalidDate(rain.chckYmd)) {
// issues.push(`점검일: 날짜 형식 아님 (${rain.chckYmd})`);
// }
// if (rain.vltnDt && isInvalidDate(rain.vltnDt)) {
// issues.push(`과태료 부과일(위반일): 날짜 형식 아님 (${rain.vltnDt})`);
// }
// // [
// // "연간운영비(원/년)", "PH", "탁도", "총대장균군수", "과태료부과금액(천원)"
// // ].forEach((key) => {
// // if (isInvalidNumber(item[key])) {
// // issues.push(`${key}: 숫자 형식 아님 (${item[key]})`);
// // }
// // }
// // );
// for (let i = 1; i <= 12; i++) {
// const month = `${i}월`;
// if (isInvalidNumber(item[`대체_${month}`])) {
// issues.push(`대체_${month}: 숫자 형식 아님 (${item[`대체_${month}`]})`);
// }
// if (isInvalidNumber(item[`빗물_${month}`])) {
// issues.push(`빗물_${month}: 숫자 형식 아님 (${item[`빗물_${month}`]})`);
// }
// }
// if (issues.length > 0) {
// errors.push(buildErrorMessage(item, issues));
// }
// });
// }
// if (errors.length > 0) {
// return { rainChkgdData: [], errors };
// }
// return { rainChkgdData, errors: [] };
// return rainChkgdData;
return { rainChkgdData, issues: [] };
};
@@ -36,6 +36,7 @@ export const rainChkZod = z.object({
cityText:z.string().nullish(),
sggText:z.string().nullish(),
prcsCpct: z.number().nullable(),
anlOperCst:z.number().nullish(),
spwtPositn: z.string().nullable(),
regDt: z.string().nullable(),
rgtr: z.string().nullable(),
@@ -150,7 +151,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
{ id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" },
{
id: "ph",
title: "PH",
title: "수소이온농도(PH)",
upName: "useQuilty",
upSequnce: 1,
type: "number",
@@ -158,7 +159,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
},
{
id: "trbt",
title: "탁도",
title: "탁도(NTU)",
upName: "useQuilty",
upSequnce: 2,
type: "number",
@@ -166,7 +167,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
},
{
id: "grssClfg",
title: "총대장균군수",
title: "총대장균군수(개/mg)",
upName: "useQuilty",
upSequnce: 3,
type: "number",
@@ -84,6 +84,7 @@ type rainChkgdnActions = {
sggCd: string,
txt: string
) => void;
setRainChkLoading:(status:boolean) =>void
};
export type rainChkgdnType = rainChkgdnState & rainChkgdnActions;
@@ -375,6 +376,17 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
} catch (error) {
console.log(error);
}
},
},setRainChkLoading:(status:boolean) =>{
set((state: rainChkgdnState) => ({
...state,
rainChkgdn: {
...state.rainChkgdn,
isLoading: status,
},
}));
}
};
};
@@ -2,6 +2,11 @@ import type { SelectDataType } from "@common/business_components/ui";
import { useTypes, type Buildingtype } from "../rainChkgdn/excel";
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type { rswtChkZodType } from ".";
import {
isInvalidDate,
isInvalidNumber,
parseRawValue,
} from "@/components/lib/func/excelFunc";
export const rswtMakeExcelSample = (
buildings: Buildingtype[],
@@ -125,17 +130,20 @@ export const rswtMakeExcelSample = (
return excelSite;
};
export const excelToRswtGuideData = (excelData: any, year: string) => {
const rainChkgdData: rswtChkZodType[] = excelData
export const excelToRswtGuideData = (
excelData: any,
year: string,
issues: string[]
) => {
const rswtChkgdData: rswtChkZodType[] = excelData
.map((item: any) => {
if (item["점검일"] !== undefined) {
const checkYmd = item["점검일"].replace(/\./g, "");
const checkYmd = item["점검일"].replace(/\./g, "")
const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
let month = `${i + 1}`;
const splyData = item[`대체수_${month}월`];
const rswtData = item[`중수_${month}월`];
const splyData = parseRawValue(item[`대체수_${month}월`]);
const rswtData = parseRawValue(item[`중수_${month}월`]);
if (month.length < 2) month = "0" + month;
return {
ym: year + month,
@@ -144,85 +152,91 @@ export const excelToRswtGuideData = (excelData: any, year: string) => {
ruseFcltUtztnQnt: rswtData !== "" ? rswtData : 0,
};
});
return {
bdstRuseFcltSn: Number(item["NO"]),
operMngCd: item["운영관리형태"],
anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
prcsCpct: item["처리용량(m³)"],
spwtPositn: item["채수지점"],
chckYmd:checkYmd,
utztnUsgCd: item["이용용도"],
guideDetails: makeGuidDetail,
rgtr: TEST_UUID,
mdfr: TEST_UUID,
};
if (checkYmd.length > 7) {
return {
bdstRuseFcltSn: Number(item["NO"]),
operMngCd: item["운영관리형태"],
anlOperCst: parseRawValue(item[`연간운영비(원/년)`]),
prcsCpct: parseRawValue(item[`처리용량(m³)`]),
spwtPositn: item["채수지점"],
chckYmd: checkYmd,
utztnUsgCd: item["이용용도"],
guideDetails: makeGuidDetail,
rgtr: TEST_UUID,
mdfr: TEST_UUID,
};
}
}
})
.filter((el: any) => el !== undefined);
return rainChkgdData;
if (rswtChkgdData.length > 0) {
rswtExcelDataCheck(rswtChkgdData,issues)
}
if (issues.length > 0) {
return { data: [], issues };
}
return { data:rswtChkgdData, issues: [] };
};
export const excelToRswtPolution = (excelData: any) => {
const rainChkgdData: rswtChkZodType[] = excelData
export const excelToRswtPolution = (excelData: any, issues: string[]) => {
const rswtChkgdData: rswtChkZodType[] = excelData
.map((item: any) => {
if (item["점검일"] !== undefined) {
const checkYmd = item["점검일"].replace(/\./g, "")
let vltnDt = item["과태료 부과일(위반일)"]
if (vltnDt !== undefined) {
vltnDt = vltnDt .replace(/\./g, "")
const checkYmd = item["점검일"].replace(/\./g, "");
let vltnDt = item["과태료 부과일(위반일)"];
if (vltnDt !== undefined) {
vltnDt = vltnDt.replace(/\./g, "");
}
const makePoluttion = Array.from({ length: 4 }, (_, i) => {
const quarter = `${i+1}`;
const grssClfgUswtr = item[`${quarter}분기_총대장균군수`];
const combResdch = item[`${quarter}분기_결합잔류염소`];
const trbt = item[`${quarter}분기_탁도`];
const bod = item[`${quarter}분기_BOD`];
const smll = item[`${quarter}분기_냄새`];
const crmty = item[`${quarter}분기_색도`];
const tph = item[`${quarter}분기_T-P`];
const tn = item[`${quarter}분기_T-N`];
const ph = item[`${quarter}분기_PH`];
const clIonQnt = item[`${quarter}분기_염화물`];
const quarter = `${i + 1}`;
const grssClfgUswtr = parseRawValue(
item[`${quarter}분기_총대장균군수`]
);
const combResdch = parseRawValue(item[`${quarter}분기_결합잔류염소`]);
const trbt = parseRawValue(item[`${quarter}분기_탁도`]);
const bod = parseRawValue(item[`${quarter}분기_BOD`]);
const smll = parseRawValue(item[`${quarter}분기_냄새`]);
const crmty = parseRawValue(item[`${quarter}분기_색도`]);
const tph = parseRawValue(item[`${quarter}분기_T-P`]);
const tn = parseRawValue(item[`${quarter}분기_T-N`]);
const ph = parseRawValue(item[`${quarter}분기_PH`]);
const clIonQnt = parseRawValue(item[`${quarter}분기_염화물`]);
return {
node: quarter,
chckYmd: checkYmd,
grssClfgUswtr: grssClfgUswtr !== "" ? grssClfgUswtr : 0,
combResdch: combResdch !== "" ? combResdch : 0,
trbt: trbt !== "" ? trbt : 0,
bod: bod !== "" ? bod : 0,
smll: smll !== "" ? smll : 0,
crmty: crmty !== "" ? crmty : 0,
tph: tph !== "" ? tph : 0,
tn: tn !== "" ? tn : 0,
ph: ph !== "" ? ph : 0,
clIonQnt: clIonQnt !== "" ? clIonQnt : 0,
grssClfgUswtr: grssClfgUswtr,
combResdch: combResdch,
trbt: trbt,
bod: bod,
smll: smll,
crmty: crmty,
tph: tph,
tn: tn,
ph: ph,
clIonQnt: clIonQnt,
rgtr: TEST_UUID,
mdfr: TEST_UUID,
};
});
return {
bdstRuseFcltSn: Number(item["NO"]),
chckYmd: checkYmd,
utztnUsgCd: item["이용용도"],
operMngCd: item["운영관리형태"],
anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
prcsCpct: item["처리용량(m³)"],
spwtPositn: item["채수지점"],
rswtrPollutions: makePoluttion,
anlOperCst: parseRawValue(item["연간운영비(원/년)"]),
prcsCpct: parseRawValue(item["처리용량(m³)"]),
spwtPositn: item["채수지점"],
rswtrPollutions: makePoluttion,
rgtr: TEST_UUID,
mdfr: TEST_UUID,
rswtrDetails: [
{
{
utztnUsgCd: item["이용용도"],
vltnDt:vltnDt,
vltnDt: vltnDt,
vltnMttr: item["위반사항"],
levyAmt: Number(item["과태료 부과금액(천원)"]) ?? 0,
rgtr: TEST_UUID,
@@ -233,5 +247,118 @@ export const excelToRswtPolution = (excelData: any) => {
}
})
.filter((el: any) => el !== undefined);
return rainChkgdData;
if (rswtChkgdData.length > 0) {
rswtExcelDataCheck(rswtChkgdData,issues)
}
if (issues.length > 0) {
return { data: [], issues };
}
return { data:rswtChkgdData, issues: [] };
};
const rswtExcelDataCheck=(rswtChkgdData:rswtChkZodType[], issues:string[]) =>{
rswtChkgdData.forEach((rswt: any) => {
const defaultMessage = `*중수도 수질 [NO: ${rswt.bdstRuseFcltSn}, 점검일: ${rswt.chckYmd}, 이용용도: ${rswt.utztnUsgCd}] 항목에서 `;
if (rswt.chckYmd && isInvalidDate(rswt.chckYmd)) {
issues.push(
defaultMessage + `점검일: 날짜 형식 아님 (${rswt.chckYmd})`
);
}
if (rswt.anlOperCst.length > 2 && isInvalidNumber(rswt.anlOperCst)) {
issues.push(
defaultMessage +
` 연간운영비(원/년): 숫자 형식 아님 (${rswt.anlOperCst})`
);
}
if (rswt.prcsCpct.length > 2 && isInvalidNumber(rswt.prcsCpct)) {
issues.push(
defaultMessage + ` 처리용량(m³): 숫자 형식 아님 (${rswt.prcsCpct})`
);
}
if (rswt?.rswtrPollutions && rswt?.rswtrPollutions.length > 0) {
rswt.rswtrPollutions.forEach((pol) => {
if (isInvalidNumber(pol.grssClfgUswtr)) {
issues.push(
defaultMessage +
`${pol.node}분기_총대장균군수: 숫자 형식 아님 (${pol.grssClfgUswtr})`
);
}
if (isInvalidNumber(pol.combResdch)) {
issues.push(
defaultMessage +
`${pol.node}분기_결합잔류염소: 숫자 형식 아님 (${pol.combResdch})`
);
}
if (isInvalidNumber(pol.trbt)) {
issues.push(
defaultMessage +
`${pol.node}분기_탁도: 숫자 형식 아님 (${pol.trbt})`
);
}
if (isInvalidNumber(pol.bod)) {
issues.push(
defaultMessage +
`${pol.node}분기_BOD: 숫자 형식 아님 (${pol.bod})`
);
}
if (isInvalidNumber(pol.smll)) {
issues.push(
defaultMessage +
`${pol.node}분기_냄새: 숫자 형식 아님 (${pol.smll})`
);
}
if (isInvalidNumber(pol.crmty)) {
issues.push(
defaultMessage +
`${pol.node}분기_색도: 숫자 형식 아님 (${pol.crmty})`
);
}
if (isInvalidNumber(pol.tph)) {
issues.push(
defaultMessage +
`${pol.node}분기_T-P: 숫자 형식 아님 (${pol.tph})`
);
}
if (isInvalidNumber(pol.tn)) {
issues.push(
defaultMessage + `${pol.node}분기_T-N: 숫자 형식 아님 (${pol.tn})`
);
}
if (isInvalidNumber(pol.ph)) {
issues.push(
defaultMessage + `${pol.node}분기_PH: 숫자 형식 아님 (${pol.ph})`
);
if (isInvalidNumber(pol.clIonQnt)) {
issues.push(
defaultMessage +
`${pol.node}분기_PH: 숫자 형식 아님 (${pol.clIonQnt})`
);
}
}
});
}
if (rswt?.rswtrDetails && rswt?.rswtrDetails.length > 0) {
rswt?.rswtrDetails.forEach((key) => {
if (key.levyAmt?.length > 1 && isInvalidNumber(key.levyAmt)) {
issues.push(
defaultMessage +
`과태료부과금액(천원): 숫자 형식 아님 (${key.levyAmt})`
);
}
if (key.vltnDt?.length > 2 && isInvalidDate(key.vltnDt)) {
issues.push(
defaultMessage +
`과태료 부과일(위반일): 날짜 형식 아님 (${key.vltnDt})`
);
}
});
}
})
}
@@ -149,26 +149,26 @@ export const rswtChkHeadListExport: TableUpperProps[] = [
{
id: "grssClfgUswtr",
title: "총대장균군수",
title: "총대장균군수(개/mg)",
upName: "useQuilty",
upSequnce: 1,
type: "number"
},
{
id: "combResdch",
title: "결합잔류염소",
title: "결합잔류염소(mh/L)",
upName: "useQuilty",
upSequnce: 2,
type: "number"
},
{ id: "trbt", title: "탁도", upName: "useQuilty", upSequnce: 3 ,type: "number"},
{ id: "bod", title: "BOD", upName: "useQuilty", upSequnce: 4 ,type: "number"},
{ id: "trbt", title: "탁도(NTU)", upName: "useQuilty", upSequnce: 3 ,type: "number"},
{ id: "bod", title: "BOD(mg/L)", upName: "useQuilty", upSequnce: 4 ,type: "number"},
{ id: "smll", title: "냄새", upName: "useQuilty", upSequnce: 5 ,type: "number"},
{ id: "crmty", title: "색도", upName: "useQuilty", upSequnce: 6 ,type: "number"},
{ id: "tn", title: "T-N", upName: "useQuilty", upSequnce: 7 ,type: "number"},
{ id: "tph", title: "T-P", upName: "useQuilty", upSequnce: 8 ,type: "number"},
{ id: "ph", title: "PH", upName: "useQuilty", upSequnce: 9,type: "number" },
{ id: "clIonQnt", title: "염화물", upName: "useQuilty", upSequnce: 10 ,type: "number"},
{ id: "crmty", title: "색도(도)", upName: "useQuilty", upSequnce: 6 ,type: "number"},
{ id: "tn", title: "총질소(T-N)(mg/L)", upName: "useQuilty", upSequnce: 7 ,type: "number"},
{ id: "tph", title: "총인(T-P)(mg/L)", upName: "useQuilty", upSequnce: 8 ,type: "number"},
{ id: "ph", title: "수소이온농도(PH)", upName: "useQuilty", upSequnce: 9,type: "number" },
{ id: "clIonQnt", title: "염화물(mg/L)", upName: "useQuilty", upSequnce: 10 ,type: "number"},
{
id: "vltnDt",
@@ -15,21 +15,21 @@ export const rainChkgdnHeadSttnExport: TableUpperProps[] = [
{ id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" },
{
id: "ph",
title: "PH",
title: "수소이온농도(PH)",
upName: "useQuilty",
upSequnce: 1,
type: "number",
},
{
id: "trbt",
title: "탁도",
title: "탁도(NTU)",
upName: "useQuilty",
upSequnce: 2,
type: "number",
},
{
id: "grssClfg",
title: "총대장균군수",
title: "총대장균군수(개/mg)",
upName: "useQuilty",
upSequnce: 3,
type: "number",
@@ -16,28 +16,28 @@ export const rswtChkSttnHeadListExport: TableUpperProps[] = [
{
id: "grssClfgUswtr",
title: "총대장균군수",
title: "총대장균군수(개/mg)",
upName: "useQuilty",
upSequnce: 1,
type: "number",
},
{
id: "combResdch",
title: "결합잔류염소",
title: "결합잔류염소(mh/L)",
upName: "useQuilty",
upSequnce: 2,
type: "number",
},
{
id: "trbt",
title: "탁도",
title: "탁도(NTU)",
upName: "useQuilty",
upSequnce: 3,
type: "number",
},
{
id: "bod",
title: "BOD",
title: "BOD(mg/L)",
upName: "useQuilty",
upSequnce: 4,
type: "number",
@@ -51,23 +51,23 @@ export const rswtChkSttnHeadListExport: TableUpperProps[] = [
},
{
id: "crmty",
title: "색도",
title: "색도(도)",
upName: "useQuilty",
upSequnce: 6,
type: "number",
},
{ id: "tn", title: "T-N", upName: "useQuilty", upSequnce: 7, type: "number" },
{ id: "tn", title: "총질소(T-N)(mg/L)", upName: "useQuilty", upSequnce: 7, type: "number" },
{
id: "tph",
title: "T-P",
title: "총인(T-P)(mg/L)",
upName: "useQuilty",
upSequnce: 8,
type: "number",
},
{ id: "ph", title: "PH", upName: "useQuilty", upSequnce: 9, type: "number" },
{ id: "ph", title: "수소이온농도(PH)", upName: "useQuilty", upSequnce: 9, type: "number" },
{
id: "clIonQnt",
title: "염화물",
title: "염화물(mg/L)",
upName: "useQuilty",
upSequnce: 10,
type: "number",
@@ -43,17 +43,17 @@ export const pbnstYearHeadListExport: TableUpperProps[] = [
},
{
id: "total",
title: "계",
title: "계(m³)",
row: 1
},
{
id: "inUsage",
title: "장내용수",
title: "장내용수(m³)",
row: 1
},
{
id: "outUsage",
title: "장외용수",
title: "장외용수(m³)",
row: 1
},
]
@@ -79,6 +79,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
if (yearHead) {
yearHead.forEach((item: { id?: string; }) => {
if (item.id) {
if(item.id === "year") {item.id = ""; return;}
item.id = i + item.id;
}
})
@@ -202,7 +203,6 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
resData.push({ ...acc, ...data })
}
})
console.log("resData", resData)
return set((state: pbnstPrfmncSttnState) => ({
...state,
pbnstPrfmncSttn: {
@@ -11,14 +11,14 @@ import type { TableUpperProps } from "@/app/store/common/type/header";
{ id: "bdstNm", title: "시설명" },
{ id: "daddr", title: "위치" },
{ id: "frstArchPrmsnDt", title: "최초건축허가일" },
{ id: "archArea", title: "건축면적", },
{ id: "archArea", title: "건축면적(㎡)", },
];
const bdstChgHeadList: TableUpperProps[] = [
{ id: "bdstChgNm", title: "구분" },
{ id: "archChgPrmsnDt", title: "허가일" },
{ id: "archChgArea", title: "변경면적" },
{ id: "archChgArea", title: "변경면적(㎡)" },
];
@@ -6,5 +6,5 @@ export const htdTableHeadList: TableUpperProps[] = [
{ id: "bdstNm", title: "시설명" },
{ id: "daddr", title: "위치" },
{ id: "frstArchPrmsnDt", title: "준공년도" },
{ id: "archArea", title: "건축면적" },
{ id: "archArea", title: "건축면적(㎡)" },
];
@@ -42,17 +42,17 @@ const hdtflObjSchema = z.object({
utztnUsg: z
.string()
.min(1, { message: validationMessages.required("이용 용도") }),
grssClfg: z.number().default(0), // Measurements, 0 is fine as default
combResdch: z.number().default(0), // Measurements, 0 is fine as default
trbt: z.number().default(0), // Measurements, 0 is fine as default
bod: z.number().default(0), // Measurements, 0 is fine as default
smll: z.number().default(0), // Measurements, 0 is fine as default
crmty: z.number().default(0), // Measurements, 0 is fine as default
tn: z.number().default(0), // Measurements, 0 is fine as default
tph: z.number().default(0), // Measurements, 0 is fine as default
ph: z.number().default(0), // Measurements, 0 is fine as default
clIonQnt: z.number().default(0), // Measurements, 0 is fine as default
cdtnv: z.number().default(0), // Measurements, 0 is fine as default
grssClfg: z.number().default(0).nullish(), // Measurements, 0 is fine as default
combResdch: z.number().default(0).nullish(), // Measurements, 0 is fine as default
trbt: z.number().default(0).nullish(), // Measurements, 0 is fine as default
bod: z.number().default(0).nullish(), // Measurements, 0 is fine as default
smll:z.string().default('').nullish(), // Measurements, 0 is fine as default
crmty: z.number().default(0).nullish(), // Measurements, 0 is fine as default
tn: z.number().default(0).nullish(), // Measurements, 0 is fine as default
tph:z.number().default(0).nullish(),// Measurements, 0 is fine as default
ph: z.string().default('').nullish(), // Measurements, 0 is fine as default
clIonQnt: z.number().default(0).nullish(), // Measurements, 0 is fine as default
cdtnv: z.number().default(0).nullish(), // Measurements, 0 is fine as default
emsnExitTp: z.number()
.max(100, { message: "온도는 100이상이 될 수 없습니다." })
.default(0), // Changed max to 100 based on message, // Measurements, 0 is fine as default
@@ -1,3 +1,4 @@
import { numSize, txtSize } from "@/app/store/common/code/basicCode";
import type { TableUpperProps } from "@/app/store/common/type/header";
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
@@ -14,8 +15,13 @@ export const pubFacHeadListExport: TableUpperProps[] = [
export const pbnstMngUpHeadListExport: TableUpperProps[] = [
{ id: "choose", title: "선택", type: "checkbox" },
{ id: "operMthd", title: "운영방식",type: "select", selectData: "ruseMngMtd" },
{ id: "rprtvBzenty", title: "대행업체", edit: true ,maxLength:10 },
{
id: "operMthd",
title: "운영방식",
type: "select",
selectData: "ruseMngMtd",
},
{ id: "rprtvBzenty", title: "대행업체", edit: true, maxLength: 10 },
{
id: "bgngDt",
title: "시작일",
@@ -47,7 +53,7 @@ export const pbnstDemandHeadListExport: TableUpperProps[] = [
export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [
{ id: "ruseUtztnFcltNm", title: "하수처리장명" },
{ id: "orgwtWtritQnt", title: "원수취수량" , type:'number'},
{ id: "orgwtWtritQnt", title: "원수취수량", type: "number" },
{ id: "tmsYn", title: "하수처리량TMS 전후" },
{ id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​" },
{ id: "dtlPstnExpln", title: "상세위치", edit: true },
@@ -60,7 +66,6 @@ export const fcOrgwtsHeadListExport: TableUpperProps[] = [
{ id: "addr", title: "위치" },
];
export const pbnstMngNmExport: chHeadType[] = [
{ headNm: "upChangeRe", text: "운영대행기간", length: 2 },
];
@@ -69,65 +74,91 @@ export type formDetailType = {
id: string;
lable: string;
type?: string;
maxLenght?: number;
selectData?: string; // select box일 경우
option?:string
option?: string;
};
export const wasteWaterFcltINfo: formDetailType[] = [
{ id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부", type: "select" , selectData: "yn"},
{ id: "tmsInstlYn", lable: "Tms설치여부", type: "select" , selectData: "yn" },
{ id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부", type: "select" , selectData: "yn" },
{
id: "wwtEmsnFcltPrmsnYn",
lable: "폐수배출물신고 허가여부",
type: "select",
selectData: "yn",
},
{ id: "tmsInstlYn", lable: "Tms설치여부", type: "select", selectData: "yn" },
{
id: "pbnstDrngInflwExclYn",
lable: "공공하수도유입제외 허가여부",
type: "select",
selectData: "yn",
},
];
export const concentratedWaterInfo: formDetailType[] = [
{ id: "erctWtrOcrnCpct", lable: "눙축수 발생량(m³/일)", type: "number" },
{ id: "erctUswtrLinkSpt", lable: "눙축수연계지점" },
{ id: "erctUswtrFcltCpct", lable: "시설용량(m³/일)", type: "number" },
{ id: "erctUswtrPrcsMeth", lable: "눙축수처리방식", type : "select", selectData: "erctUswtrPrcsMeth" },
{ id: "erctUswtrPrcsMsrcCd", lable: "눙축수처리공법" },
{ id: "erctWtrOcrnCpct", lable: "눙축수 발생량(m³/일)", type: "number",maxLenght:numSize },
{ id: "erctUswtrLinkSpt", lable: "눙축수연계지점", maxLenght:txtSize },
{ id: "erctUswtrFcltCpct", lable: "시설용량(m³/일)", type: "number" ,maxLenght:numSize },
{
id: "erctUswtrPrcsMeth",
lable: "눙축수처리방식",
type: "select",
selectData: "erctUswtrPrcsMeth",
},
{ id: "erctUswtrPrcsMsrcCd", lable: "눙축수처리공법" ,maxLenght:txtSize},
];
export const ruseFcltinfo: formDetailType[] = [
{ id: "rprcsFcltCpct", lable: "시설용량(m³/일)", type: "number" },
{ id: "majorPrcsMsrcCd", lable: "주처리공법" },
{ id: "addr", lable: "위치(주소)" },
{ id: "rprcsMthdCd", lable: "재처리방식", type: "select", selectData: "rusePrcsMthdCd" },
{ id: "inoutYn", lable: "위치(처리장 내외)" ,type: "select" , selectData: "yn"}, // 머가 내? 외?,
{ id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" },
{ id: "rprcsFcltCpct", lable: "시설용량(m³/일)", type: "number", maxLenght:numSize },
{ id: "majorPrcsMsrcCd", lable: "주처리공법", maxLenght:txtSize },
{ id: "addr", lable: "위치(주소)", maxLenght:txtSize},
{
id: "rprcsMthdCd",
lable: "재처리방식",
type: "select",
selectData: "rusePrcsMthdCd",
},
{
id: "inoutYn",
lable: "위치(처리장 내외)",
type: "select",
selectData: "yn",
}, // 머가 내? 외?,
{ id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" , maxLenght:numSize},
];
export const businessMoneyInfo: formDetailType[] = [
{ id: "gvsbs", lable: "국고", type: "number" },
{ id: "lcep", lable: "지방비", type: "number" },
{ id: "cusrAlotm", lable: "민간투자비", type: "number" },
{ id: "etc", lable: "기타" },
{ id: "totalMoney", lable: "합계", type: "number" ,option:"disabled" },
{ id: "gvsbs", lable: "국고", type: "number" , maxLenght:numSize},
{ id: "lcep", lable: "지방비", type: "number" , maxLenght:numSize},
{ id: "cusrAlotm", lable: "민간투자비", type: "number" , maxLenght:numSize},
{ id: "etc", lable: "기타" , maxLenght:numSize},
{ id: "totalMoney", lable: "합계", type: "number", option: "disabled" },
];
export const businessSttnInfo: formDetailType[] = [
{ id: "seCd", lable: "구분", type: "select", selectData: "ruseSeCd" },
{ id: "bizMthdCd", lable: "사업방식", type: "select", selectData: "ruseBizMthdCd" },
{ id: "seCd", lable: "구분", type: "select", selectData: "ruseSeCd" },
{
id: "bizMthdCd",
lable: "사업방식",
type: "select",
selectData: "ruseBizMthdCd",
},
{ id: "bizCmcnDay", lable: "사업준공일", type: "date" },
{ id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" },
];
export const ruseFcltIntakeList: formDetailType[] = [
{ id: "seCd", lable: "구분" },
{ id: "bizMthdCd", lable: "사업방식" },
{ id: "bizCmcnDay", lable: "사업준공일", type: "date" },
{ id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" },
];
export const ruseWaterQulityList: formDetailType[] = [
{ id: "bod", lable: "BOD(mg/L)", type: "text" },
{ id: "grssClfg", lable: "총대장균군수(개/mg)", type: "text" },
{ id: "combResdch", lable: "결합잔류염소(mh/L)", type: "text" },
{ id: "trbt", lable: "탁도(NTU)", type: "text" },
{ id: "smll", lable: "냄새", type: "text" },
{ id: "crmty", lable: "색도", type: "text" },
{ id: "tn", lable: "총질소(mg/L)", type: "text" },
{ id: "tph", lable: "총인(mg/L)", type: "text" },
{ id: "ph", lable: "수소이온농도", type: "text" },
{ id: "clIonQnt", lable: "염화물(mg/L)", type: "text" },
{ id: "cdtnv", lable: "전기전도도(μs/cm)​", type: "text" },
{ id: "bod", lable: "BOD(mg/L)", type: "text", maxLenght:numSize },
{ id: "grssClfg", lable: "총대장균군수(개/mg)", type: "text" , maxLenght:numSize},
{ id: "combResdch", lable: "결합잔류염소(mh/L)", type: "text" , maxLenght:numSize},
{ id: "trbt", lable: "탁도(NTU)", type: "text" , maxLenght:numSize},
{ id: "smll", lable: "냄새", type: "text", maxLenght:numSize },
{ id: "crmty", lable: "색도", type: "text", maxLenght:numSize },
{ id: "tn", lable: "총질소(mg/L)", type: "text", maxLenght:numSize },
{ id: "tph", lable: "총인(mg/L)", type: "text" , maxLenght:numSize},
{ id: "ph", lable: "수소이온농도", type: "text", maxLenght:numSize},
{ id: "clIonQnt", lable: "염화물(mg/L)", type: "text", maxLenght:numSize },
{ id: "cdtnv", lable: "전기전도도(μs/cm)​", type: "text", maxLenght:numSize },
];
@@ -59,7 +59,7 @@ export const upHeadList: TableUpperProps[] = [
{ id: "daddr", title: "위치" },
{ id: "bdsgUsgText", title: "건축물용도" },
{ id: "frstArchPrmsnDt", title: "최초건축허가일" },
{ id: "archArea", title: "건축면적" },
{ id: "archArea", title: "건축면적(㎡)" },
{ id: "lawTrgtYn", title: "법적의무대상여부" },
{ id: "bdstChgYn", title: "건축물변경여부" },
];
+13 -4
View File
@@ -96,6 +96,9 @@ import {
} from "./ruseFcltMng/fcltSttn/rswtSttn";
import { rainStatActionsExport, rainStatExport, type rainStatState, type rainStatType } from "./stats/rainStat";
import { rswtStatActionsExport, rswtStatExport, type rswtStatState, type rswtStatType } from "./stats/rswtStat";
//import { isLogin } from "./common/login";
import { LoginApi } from "@/src/entities/auth";
import { authActionsExport, authStateExport, type authState, type authType } from "./common/auth";
export type WrStore = comCodeType &
pubFacType &
@@ -122,7 +125,9 @@ export type WrStore = comCodeType &
ruseCaseType&
rainStatType&
rswtStatType&
comFcltType
comFcltType &
authType
;
export const StoreZus = (
@@ -151,7 +156,8 @@ export const StoreZus = (
drgtState&
ruseCaseState&
rainStatState&
rswtStatState
rswtStatState&
authState
= {
...comCodeStateExport,
...pubFacStateExport,
@@ -178,7 +184,8 @@ export const StoreZus = (
...ruseCaseStateExport,
...rainStatExport,
...rswtStatExport,
...comFcltStateExport
...comFcltStateExport,
...authStateExport
}
) => {
return createStore<WrStore>()((set) => {
@@ -188,6 +195,7 @@ export const StoreZus = (
getMiddleRegionCd(set);
getUnitWaterShedCd(set);
getEnvPartCd(set);
LoginApi.login({userId: "tuser10003", password: "test1234!"})
return {
...initState,
...comFcltSearchAction(set),
@@ -215,7 +223,8 @@ export const StoreZus = (
...drgtActionsExport(set),
...ruseCaseActionsExport(set),
...rainStatActionsExport(set),
...rswtStatActionsExport(set)
...rswtStatActionsExport(set),
...authActionsExport(set)
};
});
};
+18
View File
@@ -108,6 +108,24 @@ export const postFectch = async (url: string, params: any, type?: string) => {
return await response.json();
};
export const cmsPostFectch = async (url: string, params: any,headers:any) => {
const response = fetch(url, {
method: "POST",
headers:headers ,
body: JSON.stringify(params),
}).then((res) =>
{
console.log(' res ' , res)
console.log(' access-token ' , res.headers.get('access-token'))
console.log(' refresh-token ' , res.headers.get('refresh-token'))
console.log(' token-id ' , res.headers.get('token-id'))
})
return await response;
};
export const putFectch = async (url: string, params: any,type?:string) => {
const div =
type === fetchType.COMMON
+20 -13
View File
@@ -1,17 +1,24 @@
import {
PROXY_HOST,
SERVER_API_CS_TUS_URL,
SERVER_API_CS_URL,
SERVER_API_FO_URL,
SERVER_API_URL,
} from "@/src/shared/config";
const LOCAL_PORT = "3001";
const DEV_PORT = "11080";
const DEV_PORT_NEW="11082"
export const LOCAL_URL_WR = `http://localhost:${LOCAL_PORT}/api/v1`;
export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`;
//const DEV_PORT = "11080";
//const DEV_PORT_NEW="11082"
//export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`;
// export const DEV_URL_WR = `http://192.168.0.91:8880/api/v1`;
/// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`;
export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`;
//export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`;
//export const LOCAL_URL = `http://localhost:${LOCAL_PORT}`;
//export const CS_URL= 'http://dev.onasys.co.kr:8000'
//export const CS_TUS_UPLOAD= "/attach-service/api/v1/tus/upload";
export const LOCAL_URL = `http://localhost:${LOCAL_PORT}`;
export const CS_URL= 'http://dev.onasys.co.kr:8000'
export const CS_TUS_UPLOAD= "/attach-service/api/v1/tus/upload";
export const LOCAL_URL_WR = PROXY_HOST + `/api/v1`;
export const DEV_URL_WR = SERVER_API_URL;
export const DEV_URL_FO = SERVER_API_FO_URL;
export const LOCAL_URL = PROXY_HOST;
export const CS_URL = SERVER_API_CS_URL;
export const CS_TUS_UPLOAD = SERVER_API_CS_TUS_URL;
+21 -7
View File
@@ -235,7 +235,8 @@ const handleChange = (
export const InputTableBody = (
chgRes: any[] | [],
headList: TableUpperProps[],
setInputData: (data: any[]) => void
setInputData: (data: any[]) => void,
isEditable: boolean = true
) => {
// mergeCell 처리용
const getRowSpan = (data: any[], key: string, rowIndex: number) => {
@@ -265,6 +266,9 @@ export const InputTableBody = (
return (
<TableRow key={dataIndex + "row"}>
{headList.map((head, headIndex) => {
const isTextColumn = head.id === '구분' || head.id === '용수명';
const textAlignClass = isTextColumn ? 'text-center' : 'text-right';
// 총합계 행이면 "구분"에서 colSpan=2로 병합
if (
data["구분"] === 0 &&
@@ -298,10 +302,12 @@ export const InputTableBody = (
);
}
// 기본 셀
return head.edit === true && data.edit !== false ? (
// return head.edit === true && data.edit !== false ? (
return isEditable && head.edit === true && data.edit !== false ? (
<TableCell key={head.id + headIndex} className={`w-36 ${bgClass}`}>
<Input
className={`${head.id !== "utztnUsgCd" ? "text-right" : "text-center"} !text-xl h-10 w-full`}
// className={`${head.id !== "utztnUsgCd" ? "text-right" : "text-center"} !text-xl h-10 w-full`}
className={`${textAlignClass} !text-xl h-10 w-full`}
onChange={(e) =>
handleChange(dataIndex, head.id, e.target.value, setInputData)
}
@@ -312,10 +318,11 @@ export const InputTableBody = (
) : (
<TableCell key={head.id + headIndex} className={`w-36 ${bgClass}`}>
<div
className={`
${head.id !== "utztnUsgCd" ? "text-right" : "text-center"}
!text-xl w-full h-10
`}
// className={`
// ${head.id !== "utztnUsgCd" ? "text-right" : "text-center"}
// !text-xl w-full h-10
// `}
className={`${textAlignClass} !text-xl w-full h-10`}
>
{data[head.id as keyof any] ?? ""}
</div>
@@ -325,6 +332,13 @@ export const InputTableBody = (
</TableRow>
);
})}
{chgRes.length === 0 && (
<TableRow>
<TableCell colSpan={headList.length} className="h-24 text-center text-gray-500">
조회된 결과가 없습니다.
</TableCell>
</TableRow>
)}
</>
);
};
+69 -38
View File
@@ -11,9 +11,8 @@ import type { RefObject } from "react";
import toast from "react-hot-toast";
export const getCity = (val: string, sggCd: SelectDataType[]) => {
let data: any
if (val !== '0') {
let data: any;
if (val !== "0") {
data = sggCd
.filter((item) => String(item.val).substring(0, 2) === val)
.map((item) => ({
@@ -21,11 +20,10 @@ export const getCity = (val: string, sggCd: SelectDataType[]) => {
text: item.text, // 한국어 텍스트
}));
} else {
data = sggCd
.map((item) => ({
val: item.val,
text: item.text, // 한국어 텍스트
}));
data = sggCd.map((item) => ({
val: item.val,
text: item.text, // 한국어 텍스트
}));
}
data.unshift({ val: "0", text: "전체" });
return data;
@@ -118,6 +116,16 @@ export const handleCommaNumberChange = (
onChange(raw === "" ? "" : Number(raw));
};
export const handleOnlyNumberChange = (
e: React.ChangeEvent<HTMLInputElement>,
onChange: (value: number | "") => void
) => {
// 콤마 제거 후 숫자와 소수점만 남기기
const cleaned = e.target.value.replace(/,/g, "").replace(/[^0-9.]/g, "");
// 숫자 및 소수점 외 입력 차단
if (!/^\d*\.?\d*$/.test(cleaned)) return;
onChange(cleaned === "" ? "" : Number(cleaned));
};
// onchange 텍스트를 숫자로 and ,제거
export const handleMinusNumberChange = (
@@ -170,55 +178,78 @@ export const yearOptions: { val: string; text: string }[] = Array.from(
export const getdmdMatFlag = (flag: string | undefined | null) => {
const cleanFlag = (flag ?? "").trim();
switch (cleanFlag) {
case "Sub":
return "검토";
case "Matched":
return "매칭완료";
case "Checked":
return '검토완료';
return "검토완료";
default:
return "신청";
}
};
export const formatPhoneNumber = (tel: string) => {
const onlyNums = tel.replace(/[^0-9]/g, '');
const onlyNums = tel.replace(/[^0-9]/g, "");
if (onlyNums.length === 10) {
return onlyNums.replace(/(\d{2})(\d{4})(\d{4})/, '$1-$2-$3');
return onlyNums.replace(/(\d{2})(\d{4})(\d{4})/, "$1-$2-$3");
} else if (onlyNums.length === 11) {
return onlyNums.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3');
return onlyNums.replace(/(\d{3})(\d{4})(\d{4})/, "$1-$2-$3");
} else {
return tel; // 유효하지 않으면 빈 문자열
}
}
};
export const confirmToast = (content: string, saveFunc: () => void) => {
toast((t) => (
<span className="flex flex-col items-center">
<div className="mb-6">
{content}
</div>
<div className="flex flex-row space-x-2">
<Button
size={"sm"}
onClick={() => {
saveFunc();
toast.dismiss(t.id);
}}
>
확인
</Button>
<Button
size={"sm"}
onClick={() => toast.dismiss(t.id)}>취소</Button>
</div>
</span>
),
toast(
(t) => (
<span className="flex flex-col items-center">
<div className="mb-6">{content}</div>
<div className="flex flex-row space-x-2">
<Button
size={"sm"}
onClick={() => {
saveFunc();
toast.dismiss(t.id);
}}
>
확인
</Button>
<Button size={"sm"} onClick={() => toast.dismiss(t.id)}>
취소
</Button>
</div>
</span>
),
{
id: "global-confirm-toast", // 중복 토스트 방지
duration: Infinity, // 자동 사라짐 방지
});
}
}
);
};
export const showConfirmToast = (message: string) => {
toast.custom(
(t) => (
<div
className={`w-[500px] min-h-[140px] bg-white shadow-lg rounded-xl p-6 border border-gray-200
${t.visible ? "animate-enter" : "animate-leave"}`}
>
<div className="text-3xl font-extrabold text-red-600 bg-yellow-100 px-4 py-2 rounded-md shadow-md">
{message}
</div>{" "}
<div className="flex justify-end gap-2">
<Button
size={"sm"}
className="px-4 py-1.5 rounded bg-gray-200 text-sm hover:bg-gray-300"
onClick={() => toast.dismiss(t.id)}
>
확인완료
</Button>
</div>
</div>
),
{ duration: Infinity }
); // 수동 닫기
};
+17
View File
@@ -0,0 +1,17 @@
// ✨ 오류 검사 - 가공된 데이터 기준
export const isInvalidNumber = (val: any) => {
return val !== undefined && val !== null && val !== "" && isNaN(Number(val));
};
export const isInvalidDate = (val: any) => {
//yyyymmdd 즉 20201212 이런형식만 허용
return !(typeof val === "string" && /^\d{8}$/.test(val.trim()));
};
export const parseRawValue = (val: any): number | string => {
if (val === "" || val === undefined || val === null) return 0;
if (typeof val === "string" && ["보류", "N/A"].includes(val.trim()))
return val;
return !isNaN(val) && val !== " " ? Number(val) : val;
};
+88
View File
@@ -0,0 +1,88 @@
import {
initValInUsage,
initValOutUsage,
subTotalObj,
totalObj,
type PrfType,
type PrfUsageSummary,
} from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
export const getTablePrfData = (prfList: PrfType[]) => {
const inUsageData = structuredClone(initValInUsage);
const outUsageData = structuredClone(initValOutUsage);
const inSubtotal = structuredClone(subTotalObj);
const outSubtotal = structuredClone(subTotalObj);
if (prfList) {
prfList?.forEach((prfItem) => {
const month = Number(prfItem?.ym?.slice(4)); // "MM"
const monthKey = `${month}월`;
inUsageData.forEach((inData: PrfUsageSummary) => {
const usageKey = inData.usage as keyof PrfType;
const value = (prfItem[usageKey] as number) ?? 0;
(inData[monthKey as keyof PrfUsageSummary] as number) = value;
inData.total += value;
if (inSubtotal&& usageKey !== "subtotal" as keyof PrfType) {
(inSubtotal[monthKey as keyof PrfUsageSummary] as number) =
((inSubtotal[monthKey as keyof PrfUsageSummary] as number) ?? 0) +
value;
inSubtotal.total += value;
}
});
outUsageData.forEach((outData: PrfUsageSummary) => {
const usageKey = outData.usage as keyof PrfType;
const value = (prfItem[usageKey] as number) ?? 0; // Type assertion for prfItem[usageKey]
(outData[monthKey as keyof PrfUsageSummary] as number) = value;
outData.total += value;
if (outSubtotal && usageKey !== "subtotal" as keyof PrfType) {
(outSubtotal [monthKey as keyof PrfUsageSummary] as number) =
((outSubtotal[monthKey as keyof PrfUsageSummary] as number) ?? 0) + value;
outSubtotal.total += value;
} // End of if (outSubtotal && usageKey !== "subtotal")
}); // End of outUsageData.forEach
});
(inSubtotal as any)["구분"] = "장내용수";
(outSubtotal as any)["구분"] = "장내용수";
inUsageData.push(inSubtotal);
outUsageData.push(outSubtotal);
const usageTotalObj: { [key: string]: any } = structuredClone(totalObj);
for (const key in usageTotalObj) {
if (["usage", "gubun", "edit"].includes(key)) continue;
const val =
(Number((inSubtotal as any)[key]) || 0) +
(Number((outSubtotal as any)[key]) || 0);
(usageTotalObj as any)[key] = val;
}
const tableData = [...inUsageData, ...outUsageData, usageTotalObj];
return {
inPrf: inUsageData,
outPrf: outUsageData,
totalPrf: tableData,
};
}
};
// const usageKey = inData.usage as keyof PrfType;
// const value = (prfItem[usageKey] as number) ?? 0;
// (inData[monthKey as keyof PrfUsageSummary] as number) = value;
// inData.total += value;
// if (inSubtotal&& usageKey !== "subtotal" as keyof PrfType) {
// (inSubtotal[monthKey as keyof PrfUsageSummary] as number) =
// ((inSubtotal[monthKey as keyof PrfUsageSummary] as number) ?? 0) +
// value;
// inSubtotal.total += value;
// }
@@ -232,7 +232,7 @@ export default function ConCostForm({
>
저장
</Button>
<Label>검토완료</Label>
<Label>검토완료</Label>
<Checkbox
className="ml-3 mr-6"
checked={checkFinish}
@@ -267,6 +267,7 @@ export default function ConCostForm({
field.onChange(e.target.value);
}}
value={field.value ?? ""}
readOnly={true}
/>
</FormUi>
)}
@@ -286,6 +287,7 @@ export default function ConCostForm({
field.onChange(Number(e.target.value));
}}
value={field.value ?? 0}
readOnly={true}
/>
</FormUi>
)}
@@ -331,6 +333,7 @@ export default function ConCostForm({
onChange={field.onChange}
value={field.value ?? ""}
className="mt-2"
readOnly={true}
/>
</FormUi>
)}
@@ -358,7 +361,7 @@ export default function ConCostForm({
/>
</div>
<div className="col-span-12 w-full">
<h1 className={formH1Class}>공사비 입력사항</h1>
<h1 className={formH1Class}>공사비 입력사항</h1>
</div>
<div className="col-span-2 mt-4">
@@ -1,6 +1,7 @@
"use client";
import { useWrStore } from "@/app/store";
import { numSize } from "@/app/store/common/code/basicCode";
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { formH1Class } from "@/components/lib/class/comClass";
import { safeDate } from "@/components/lib/func/commom";
@@ -94,6 +95,7 @@ export default function BdstAdd({ form, readonly }: { form: any; readonly?: bool
value={f.value ?? code.chBuCd[0]?.val}
className={""}
label={""}
readOnly={readonly}
/>
</FormUi>
)}
@@ -113,6 +115,7 @@ export default function BdstAdd({ form, readonly }: { form: any; readonly?: bool
onChange: (date) => f.onChange(date),
}}
selectClass="w-full"
readOnly={readonly}
/>
</FormUi>
)}
@@ -123,13 +126,15 @@ export default function BdstAdd({ form, readonly }: { form: any; readonly?: bool
control={form.control}
name={`chgBuilding.${index}.archChgArea`}
render={({ field: f }) => (
<FormUi label="면적">
<FormUi label="면적(㎡)">
<Input
placeholder="-"
type="text"
onChange={(e) => f.onChange(e.target.value)}
value={f.value || ''}
className={selectClass}
readOnly={readonly}
maxLength={numSize}
/>
</FormUi>
)}
@@ -1,6 +1,8 @@
import { useWrStore } from "@/app/store";
import { numSize, txtSize } from "@/app/store/common/code/basicCode";
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { formH1Class } from "@/components/lib/class/comClass";
import { handleCommaNumberChange } from "@/components/lib/func/commom";
import {
FormField,
FormUi,
@@ -134,6 +136,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
field.onChange(e.target.value)
}}
value={field.value||''}
maxLength={txtSize}
/>
</FormUi>
)}
@@ -153,6 +156,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
field.onChange(e.target.value)
}}
value={field.value||''}
maxLength={50}
/>
</FormUi>
)}
@@ -217,9 +221,10 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
placeholder="면적을 입력하세요"
type="text"
onChange={(e) => {
field.onChange(e.target.value)
handleCommaNumberChange(e, field.onChange);
}}
value={field.value||''}
maxLength={numSize}
/>
</FormUi>
)}
@@ -12,6 +12,7 @@ import {
confirmToast,
formatCommaNumber,
handleCommaNumberChange,
handleOnlyNumberChange,
} from "@/components/lib/func/commom";
import {
Form,
@@ -19,9 +20,9 @@ import {
FormUi,
SelectBox,
} from "@common/business_components/ui";
import { Button, Input, ScrollArea } from "@common/components/ui";
import { Button, Input, Label, ScrollArea } from "@common/components/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import toast from "react-hot-toast";
import { useTranslation } from "react-i18next";
@@ -40,6 +41,8 @@ export default function HtdflRegForm({
setIsModal?: (modal: boolean) => void;
}) {
const { code, htdflBdstUpdate, htdflBdstReg } = useWrStore((state) => state);
const [frontPHdata, setFrontPHdata] = useState("");
const [backPHdata, setBackPHdata] = useState("");
const defaultValues: z.infer<typeof hdtflZod> = hdtflZod.parse({});
@@ -51,7 +54,7 @@ export default function HtdflRegForm({
const bdstNm = form.watch("bdstNm");
const isPowerPlant = bdstNm?.includes("발전소");
const { t } = useTranslation('base');
const { t } = useTranslation("base");
const onSubmit = (values: z.infer<typeof hdtflZod>) => {
if (isModal) {
const data = regCtpvCd ? regCtpvCd : regSggcd ? regSggcd : "noCd";
@@ -63,13 +66,12 @@ export default function HtdflRegForm({
htdflBdstReg(values, data);
if (setIsModal) setIsModal(false);
};
confirmToast(t('isInsertMsg'), handleConfirm);
confirmToast(t("isInsertMsg"), handleConfirm);
} else {
const handleConfirm = async () => {
htdflBdstUpdate(values, "0");
};
confirmToast(t('isUpdateMsg'), handleConfirm);
confirmToast(t("isUpdateMsg"), handleConfirm);
}
};
@@ -97,14 +99,53 @@ export default function HtdflRegForm({
})),
};
};
const isSetFrontPh = useCallback(
(frontPHdata: string) => {
setFrontPHdata(frontPHdata);
if (!frontPHdata) {
form.setValue(`reuseBuilding.0.htdflObj.ph`, "");
return;
}
const PHdata = form.getValues(`reuseBuilding.0.htdflObj.ph`);
let backPH;
if (PHdata && String(PHdata).includes("~")) {
backPH = PHdata.split("~")[1];
} else {
backPH = String(Number(frontPHdata) + 1);
}
const MatchData = `${frontPHdata}~${backPH}`;
form.setValue(`reuseBuilding.0.htdflObj.ph`, MatchData);
},
[form]
);
const isSetBackPh = useCallback(
(backPHdata: string) => {
setBackPHdata(backPHdata);
if (!backPHdata) {
form.setValue(`reuseBuilding.0.htdflObj.ph`, "");
return;
}
const PHdata = form.getValues(`reuseBuilding.0.htdflObj.ph`);
let frontPH;
if (PHdata && String(PHdata).includes("~")) {
frontPH = PHdata.split("~")[0];
} else {
frontPH = String(Math.max(Number(backPHdata) - 1, 0));
}
const MatchData = `${frontPH}~${backPHdata}`;
form.setValue(`reuseBuilding.0.htdflObj.ph`, MatchData);
},
[form]
);
const [divStyle, setDivStyle] = useState("h-[53vh]");
useEffect(() => {
if (isModal === true) {
setDivStyle("h-[53vh] max-h-[37vh]")
setDivStyle("h-[53vh] max-h-[37vh]");
} else if (readonly === true) {
setDivStyle("h-[62vh]")
setDivStyle("h-[62vh]");
} else {
setDivStyle("h-[53vh]")
setDivStyle("h-[53vh]");
}
}, [isModal, readonly]);
@@ -116,7 +157,25 @@ export default function HtdflRegForm({
useEffect(() => {
// Case 1: 수정 또는 '복사하여 등록' 등 데이터가 주입되는 경우
if (htdflForm && Object.keys(htdflForm).length > 0) {
const htdflPH = htdflForm.reuseBuilding[0]?.htdflObj.ph
if(htdflPH && String(htdflPH).includes("~")){
const [frontPH, backPH] = htdflPH.split("~");
if (frontPH) {
setFrontPHdata(frontPH);
}
if (backPH) {
setBackPHdata(backPH);
}
} else {
setFrontPHdata("");
setBackPHdata("");
}
form.reset(cleanHtdflData(htdflForm));
}else{
form.reset();
}
// Case 2: 데이터가 없는 순수 신규 등록 모드인 경우
if (isModal) {
@@ -125,15 +184,33 @@ export default function HtdflRegForm({
const firstHtdUtztnUsgCd = code.htdUtztnUsgCd?.[0]?.val;
if (firstHtdPowerMthdCd) {
form.setValue('reuseBuilding.0.htdflObj.etgtType', firstHtdPowerMthdCd, { shouldDirty: true });
form.setValue(
"reuseBuilding.0.htdflObj.etgtType",
firstHtdPowerMthdCd,
{ shouldDirty: true }
);
}
if (firstYnValue) {
form.setValue('reuseBuilding.0.htdflObj.plwtYn', firstYnValue as "Y" | "N", { shouldDirty: true });
form.setValue('reuseBuilding.0.htdflObj.prcsProcsYn', firstYnValue as "Y" | "N", { shouldDirty: true });
form.setValue('reuseBuilding.0.htdflObj.fmYn', firstYnValue as "Y" | "N", { shouldDirty: true });
form.setValue(
"reuseBuilding.0.htdflObj.plwtYn",
firstYnValue as "Y" | "N",
{ shouldDirty: true }
);
form.setValue(
"reuseBuilding.0.htdflObj.prcsProcsYn",
firstYnValue as "Y" | "N",
{ shouldDirty: true }
);
form.setValue(
"reuseBuilding.0.htdflObj.fmYn",
firstYnValue as "Y" | "N",
{ shouldDirty: true }
);
}
if (firstHtdUtztnUsgCd) {
form.setValue('reuseBuilding.0.htdflObj.utztnUsg', firstHtdUtztnUsgCd, { shouldDirty: true });
form.setValue("reuseBuilding.0.htdflObj.utztnUsg", firstHtdUtztnUsgCd, {
shouldDirty: true,
});
}
}
}, [htdflForm, code, form]);
@@ -142,12 +219,37 @@ export default function HtdflRegForm({
if (!isPowerPlant) {
form.setValue(
"reuseBuilding.0.htdflObj.etgtType",
"해당없음", // 빈 문자열로 초기화
{ shouldDirty: true } // dirty 상태로 남길지 여부는 취사선택
"해당없음", // 빈 문자열로 초기화
{ shouldDirty: true } // dirty 상태로 남길지 여부는 취사선택
);
}
}, [isPowerPlant, form]);
// useEffect(() => {
// const watchPH = form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.ph`);
// const checkPkAndCycle =
// form.getValues(`items.${indexMng}.pbnstRuseFcltId`) +
// String(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cycl`));
// console.log("checkPkAndCycle ", checkPkAndCycle);
// if (chekcPk !== checkPkAndCycle) {
// if (watchPH && watchPH !== undefined) {
// const [frontPH, backPH] = watchPH.split("~");
// if (frontPH) {
// setFrontPHdata(frontPH);
// }
// if (backPH) {
// setBackPHdata(backPH);
// }
// } else {
// setFrontPHdata("0");
// setBackPHdata("0");
// }
// setCheakPk(checkPkAndCycle);
// }
// }, [form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.ph`), chekcPk]);
return (
<div className="!mx-[1.6rem] !p-0r">
<Form {...form}>
@@ -198,9 +300,13 @@ export default function HtdflRegForm({
label={""}
selectClass={selectClass}
selectArray={code.htdPowerMthdCd}
onSelectValue={readonly ? () => { } : field.onChange}
onSelectValue={readonly ? () => {} : field.onChange}
// value={field.value ?? ""}
value={field.value || (code?.htdPowerMthdCd[0] &&code?.htdPowerMthdCd[0].val)}
value={
field.value ||
(code?.htdPowerMthdCd[0] &&
code?.htdPowerMthdCd[0].val)
}
readOnly={readonly || !isPowerPlant}
/>
</FormUi>
@@ -241,7 +347,7 @@ export default function HtdflRegForm({
label={""}
selectClass={selectClass}
selectArray={code.yn}
onSelectValue={readonly ? () => { } : field.onChange}
onSelectValue={readonly ? () => {} : field.onChange}
value={field.value ?? ""}
readOnly={readonly}
/>
@@ -265,9 +371,9 @@ export default function HtdflRegForm({
className={selectClass}
placeholder=""
type="text"
value={field.value ?? ''}
value={field.value ?? ""}
onChange={(e) => {
if (!readonly) field.onChange((e.target.value));
if (!readonly) field.onChange(e.target.value);
}}
readOnly={readonly}
maxLength={txtSize}
@@ -374,7 +480,7 @@ export default function HtdflRegForm({
label={""}
selectClass={selectClass}
selectArray={code.yn}
onSelectValue={readonly ? () => { } : field.onChange}
onSelectValue={readonly ? () => {} : field.onChange}
value={field.value ?? ""}
readOnly={readonly}
/>
@@ -415,7 +521,7 @@ export default function HtdflRegForm({
selectClass={selectClass}
label={""}
selectArray={code.yn}
onSelectValue={readonly ? () => { } : field.onChange}
onSelectValue={readonly ? () => {} : field.onChange}
value={field.value ?? ""}
readOnly={readonly}
/>
@@ -456,7 +562,7 @@ export default function HtdflRegForm({
selectClass={selectClass}
label={""}
selectArray={code.htdUtztnUsgCd}
onSelectValue={readonly ? () => { } : field.onChange}
onSelectValue={readonly ? () => {} : field.onChange}
value={field.value ?? ""}
readOnly={readonly}
/>
@@ -476,19 +582,26 @@ export default function HtdflRegForm({
control={form.control}
name="reuseBuilding.0.htdflObj.grssClfg"
render={({ field }) => (
<FormUi label="총대장균군">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="총대장균군(개/mg)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
@@ -499,19 +612,26 @@ export default function HtdflRegForm({
control={form.control}
name="reuseBuilding.0.htdflObj.tn"
render={({ field }) => (
<FormUi label="총질소">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="총질소(T-N)(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder=""
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={6}
/>{" "}
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
@@ -524,7 +644,7 @@ export default function HtdflRegForm({
control={form.control}
name="reuseBuilding.0.htdflObj.combResdch"
render={({ field }) => (
<FormUi label="결합잔류염소">
<FormUi label="결합잔류염소(mh/L)">
<Input
className={selectClass}
placeholder="10"
@@ -547,19 +667,26 @@ export default function HtdflRegForm({
control={form.control}
name="reuseBuilding.0.htdflObj.tph"
render={({ field }) => (
<FormUi label="총인">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="총인(T-P)(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
@@ -572,42 +699,58 @@ export default function HtdflRegForm({
control={form.control}
name="reuseBuilding.0.htdflObj.trbt"
render={({ field }) => (
<FormUi label="탁도">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="탁도(NTU)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
handleOnlyNumberChange(e, field.onChange);
}}
value={
field.value !== undefined && field.value !== 0
? `${field.value}`
: ""
}
readOnly={readonly}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이상
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className="col-span-6">
<FormField
control={form.control}
name="reuseBuilding.0.htdflObj.ph"
name="reuseBuilding.0.htdflObj.crmty"
render={({ field }) => (
<FormUi label="수소이온농도">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="색도(도)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이상
</span>
</div>
</div>
</FormUi>
)}
/>
@@ -620,19 +763,26 @@ export default function HtdflRegForm({
control={form.control}
name="reuseBuilding.0.htdflObj.bod"
render={({ field }) => (
<FormUi label="생물학적 산소요구량">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="생물학적 산소요구량(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
@@ -643,19 +793,26 @@ export default function HtdflRegForm({
control={form.control}
name="reuseBuilding.0.htdflObj.clIonQnt"
render={({ field }) => (
<FormUi label="염화물">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="염화물(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={7}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
@@ -669,69 +826,83 @@ export default function HtdflRegForm({
name="reuseBuilding.0.htdflObj.smll"
render={({ field }) => (
<FormUi label="냄새">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
<SelectBox
className={"!text-2xl"}
label={""}
selectClass={undefined}
selectArray={[
{ val: "불쾌하지않을것", text: "불쾌하지않을것" },
{ val: "없음", text: "없음" },
]}
readOnly={readonly}
maxLength={numSize}
/>
onSelectValue={(val) => {
field.onChange(val);
}}
value={field.value || undefined}
></SelectBox>
</FormUi>
)}
/>
</div>
<div className="col-span-6">
<FormField
control={form.control}
name="reuseBuilding.0.htdflObj.cdtnv"
render={({ field }) => (
<FormUi label="전기전도도">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<FormUi label="전기전도도(μs/cm)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
</div>
<div className="grid grid-cols-12 gap-4">
<div className="col-span-6">
<FormField
control={form.control}
name="reuseBuilding.0.htdflObj.crmty"
render={({ field }) => (
<FormUi label="색도">
<Input
className={selectClass}
placeholder="10"
type="text"
onChange={(e) => {
if (!readonly)
handleCommaNumberChange(e, field.onChange);
}}
value={formatCommaNumber(field.value)}
readOnly={readonly}
maxLength={numSize}
/>
</FormUi>
)}
/>
<Label className="text-xl">수소이온농도(PH)</Label>
<div className="flex flex-row items-center gap-2">
<Input
className="!text-xl w-1/2"
placeholder=""
type="text"
onChange={(e) =>
//setFrontPHdata(e.target.value)
isSetFrontPh(e.target.value)
}
value={frontPHdata ?? ""}
readOnly={readonly}
maxLength={3}
/>
<span className="text-xl">~</span>
<Input
className="!text-xl w-1/2"
placeholder=""
type="text"
onChange={(e) => {
isSetBackPh(e.target.value);
}}
value={backPHdata ?? ""}
readOnly={readonly}
maxLength={3}
/>
</div>
</div>
</div>
</ScrollArea>
@@ -6,7 +6,6 @@ import {
businessSttnInfo,
concentratedWaterInfo,
ruseFcltinfo,
ruseWaterQulityList,
wasteWaterFcltINfo,
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList";
import {
@@ -38,6 +37,7 @@ import SdmInsertForm from "@common/business_components/ui/sdmInsertForm";
import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm";
import type { SelectDataType } from "@common/business_components";
import { BuseWaterQulity } from "./buseWaterQulity/buseWaterQulity";
export function PbnstBuseForm({
indexMng = 0,
@@ -474,7 +474,7 @@ export function PbnstBuseForm({
/>
</div>
<MngRegFormDetail
{/* <MngRegFormDetail
formList={ruseWaterQulityList}
h1Title={`하수처리수 재이용시설 보증수질 `}
subTitle="※재처리시설이 있는 경우만 작성"
@@ -483,7 +483,21 @@ export function PbnstBuseForm({
sonClass="col-span-4"
indexMng={indexMng}
indexBiz={indexBiz}
/> */}
<div>
<BuseWaterQulity
h1Title={`하수처리수 재이용시설 보증수질 `}
subTitle="※재처리시설이 있는 경우만 작성"
form={form}
moClass="grid grid-cols-12 gap-4"
sonClass="col-span-4"
indexMng={indexMng}
indexBiz={indexBiz}
formType={""}
/>
</div>
<div key={"hasu"}>
<h1 className={formH1Class}>
{"하수처리수 재이용수 수요처"}
@@ -0,0 +1,495 @@
import type { PbnstRegArrrayType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
import { formH1Class } from "@/components/lib/class/comClass";
import { FormField, FormUi, SelectBox } from "@common/business_components/ui";
import { Input, Label } from "@common/components/ui";
import { useCallback, useEffect, useState } from "react";
import type { UseFormReturn } from "react-hook-form";
export function BuseWaterQulity({
form,
h1Title,
subTitle,
moClass,
sonClass,
indexMng,
indexBiz,
formType,
}: {
form: UseFormReturn<{ items: PbnstRegArrrayType }>;
h1Title: string;
subTitle: string;
moClass: string;
sonClass: string;
indexMng: number;
indexBiz: number;
formType?: string;
}) {
const [frontPHdata, setFrontPHdata] = useState("0");
const [backPHdata, setBackPHdata] = useState("0");
const [chekcPk, setCheakPk] = useState("");
// const watchPH = useWatch({
// name: `items.${indexMng}.fcBizs.${indexBiz}.ph`,
// control: form.control, // useForm에서 받은 control 전달
// });
useEffect(() => {
const watchPH = form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.ph`);
const checkPkAndCycle =
form.getValues(`items.${indexMng}.pbnstRuseFcltId`) +
String(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cycl`));
console.log("checkPkAndCycle ", checkPkAndCycle);
if (chekcPk !== checkPkAndCycle) {
if (watchPH && watchPH !== undefined) {
const [frontPH, backPH] = watchPH.split("~");
if (frontPH) {
setFrontPHdata(frontPH);
}
if (backPH) {
setBackPHdata(backPH);
}
} else {
setFrontPHdata("0");
setBackPHdata("0");
}
setCheakPk(checkPkAndCycle);
}
}, [form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.ph`), chekcPk]);
const isSetFrontPh = useCallback(
(frontPHdata: string) => {
if (frontPHdata && frontPHdata.length > 0) {
const PHdata = form.getValues(
`items.${indexMng}.fcBizs.${indexBiz}.ph`
);
if (PHdata) {
const backPH = PHdata.split("~")[1];
const MatchData = frontPHdata + "~" + backPH;
form.setValue(`items.${indexMng}.fcBizs.${indexBiz}.ph`, MatchData);
setFrontPHdata(frontPHdata);
} else {
const MatchData = frontPHdata + "~" + "0";
form.setValue(`items.${indexMng}.fcBizs.${indexBiz}.ph`, MatchData);
setFrontPHdata(frontPHdata);
}
}
},
[frontPHdata, form, indexMng, indexBiz]
);
const isSetBackPh = useCallback(
(backPHdata: string) => {
if (backPHdata && backPHdata.length > 0) {
const PHdata = form.getValues(
`items.${indexMng}.fcBizs.${indexBiz}.ph`
);
if (PHdata) {
const frontPH = PHdata.split("~")[0];
const MatchData = frontPH + "~" + backPHdata;
console.log(" backPHdata ", MatchData);
form.setValue(`items.${indexMng}.fcBizs.${indexBiz}.ph`, MatchData);
setBackPHdata(backPHdata);
} else {
const MatchData = "0" + "~" + backPHdata;
form.setValue(`items.${indexMng}.fcBizs.${indexBiz}.ph`, MatchData);
setBackPHdata(backPHdata);
}
}
},
[backPHdata, form, indexMng, indexBiz]
);
return (
<>
{h1Title ? <h1 className={formH1Class}>{h1Title}</h1> : <></>}
{subTitle ? <h3 className={"items-center"}>{subTitle}</h3> : <></>}
<div className={moClass}>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.bod`}
key={`items.${indexMng}.fcBizs.${indexBiz}.bod-key`}
render={({ field }) => (
<FormUi label="BOD(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
{
//TODO 불검춣확인필요
}
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.grssClfg`}
key={`items.${indexMng}.fcBizs.${indexBiz}.grssClfg-key`}
render={({ field }) => (
<FormUi label="총대장균군수(개/mg)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={6}
/>
{/* TODO: 총대장균군수 확인 필요*/}
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.combResdch`}
key={`items.${indexMng}.fcBizs.${indexBiz}.combResdch-key`}
render={({ field }) => (
<FormUi label="결합잔류염소(mh/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이상
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.trbt`}
key={`items.${indexMng}.fcBizs.${indexBiz}.trbt-key`}
render={({ field }) => (
<FormUi label="탁도(NTU)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이상
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
{
//TODO : 확인필요
}
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.smll`}
key={`items.${indexMng}.fcBizs.${indexBiz}.smll-key`}
render={({ field }) => (
<FormUi label="냄새">
{/* <Input
className="!text-2xl"
placeholder=""
type="text"
onChange={(e) => {
field.onChange(String(e.target.value));
}}
value={field.value ?? ""}
readOnly={formType === "sttn" ? true : false}
maxLength={txtSize}
/> */}
<SelectBox
className={"!text-2xl"}
label={""}
selectClass={undefined}
selectArray={[
{ val: "불쾌하지않을것", text: "불쾌하지않을것" },
{ val: "없음", text: "없음" },
]}
readOnly={formType === "sttn" ? true : false}
onSelectValue={(val) => {
field.onChange(val);
}}
value={field.value || undefined}
></SelectBox>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.crmty`}
key={`items.${indexMng}.fcBizs.${indexBiz}.crmty-key`}
render={({ field }) => (
<FormUi label="색도(도)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.tn`}
key={`items.${indexMng}.fcBizs.${indexBiz}.tn-key`}
render={({ field }) => (
<FormUi label="총질소(T-N)(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.tph`}
key={`items.${indexMng}.fcBizs.${indexBiz}.tph-key`}
render={({ field }) => (
<FormUi label="총인(T-P)(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={6}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.cdtnv`}
key={`items.${indexMng}.fcBizs.${indexBiz}.cdtnv-key`}
render={({ field }) => (
<FormUi label="전기전도도(μs/cm)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={7}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className={sonClass}>
<FormField
control={form.control}
name={`items.${indexMng}.fcBizs.${indexBiz}.clIonQnt`}
key={`items.${indexMng}.fcBizs.${indexBiz}.clIonQnt-key`}
render={({ field }) => (
<FormUi label="염화물(mg/L)">
<div className="flex items-center gap-2">
<div className="relative flex-1 min-w-0">
<Input
type="text"
className="w-full pr-16 border py-2 text-right rounded-md"
placeholder=""
onChange={(e) => {
const inputValue = e.target.value.replace(/[^0-9.]/g, ""); // 숫자만 저장
field.onChange(inputValue);
}}
value={
field.value !== undefined && field.value !== ""
? `${field.value}`
: ""
}
readOnly={formType === "sttn" ? true : false}
maxLength={7}
/>
<span className="text-xl absolute inset-y-0 right-3 flex items-center text-gray-500 pointer-events-none">
이하
</span>
</div>
</div>
</FormUi>
)}
/>
</div>
<div className="col-span-8">
<Label className="text-xl">수소이온농도(PH)</Label>
<div className="flex flex-row items-center gap-2">
<Input
className="!text-xl w-28"
placeholder=""
type="text"
onChange={(e) =>
//setFrontPHdata(e.target.value)
isSetFrontPh(e.target.value)
}
value={frontPHdata ?? ""}
readOnly={formType === "sttn"}
maxLength={3}
/>
<span className="text-xl">~</span>
<Input
className="!text-xl w-28"
placeholder=""
type="text"
onChange={(e) => {
isSetBackPh(e.target.value);
}}
value={backPHdata ?? ""}
readOnly={formType === "sttn"}
maxLength={3}
/>
</div>
</div>
</div>
</>
);
}
@@ -253,7 +253,7 @@ export default function RswtrRegForm({
const isUnknown = value === null || value === -1; // 또는 Number(value) === -1
return (
<FormUi label="처리시설 용량">
<FormUi label="처리시설 용량(m³)">
<Input
className={selectClass}
placeholder=""
@@ -7,6 +7,7 @@ import {
excelToRswtGuideData,
excelToRswtPolution,
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel";
import { showConfirmToast } from "@/components/lib/func/commom";
import {
filePicked,
filePickedArray,
@@ -18,22 +19,38 @@ import {
} from "@common/business_components/ui";
import { Button, Input } from "@common/components/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { useForm } from "react-hook-form";
import toast from "react-hot-toast";
import type { z } from "zod";
export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type: string, setIsRegExcel:(open:boolean) =>void ,setYearChange:(year:string)=> void }) {
const { rainChkExcelDataUPload, rswtChkExceDataUpload } =
useWrStore((state) => {
return state;
});
export default function ChkgdExcel({
type,
setIsRegExcel,
setYearChange,
}: {
type: string;
setIsRegExcel: (open: boolean) => void;
setYearChange: (year: string) => void;
}) {
const {
rainChkExcelDataUPload,
rswtChkExceDataUpload,
setRainChkLoading,
} = useWrStore((state) => {
return state;
});
const [excelData, setExcelData] = useState<
rswtChkZodType[] | rainChkZodType[]
>();
const [file, setFile] = useState<File | null>(null);
const clearFile = () => {
if (fileInputRef.current) {
fileInputRef.current.value = ""; // ✅ 파일 선택 비우기
}
};
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const selectedFile = e.target.files?.[0];
if (selectedFile) {
@@ -41,6 +58,7 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
}
};
const [excelRswtData, setExcelRswtData] = useState<rswtChkZodType[]>();
const fileInputRef = useRef<HTMLInputElement>(null);
const currentYear = new Date().getFullYear();
const startYear = 1970;
@@ -70,70 +88,83 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
}
if (file)
if (type === "RNB") {
filePicked(file, 0).then((res) => {
// if (res !== undefined){
const excelData = excelToRainChkData(res, form.getValues("chckYr"))
if(res !== undefined)
setExcelData(excelData)
// if( excelData&&excelData.errors.length>0){
// excelData.errors.forEach((err) =>{
// toast.error(err)
// })
// }else{
// }
// }
})
setRainChkLoading(true);
filePicked(file, 0)
.then(async (res) => {
const excelData = excelToRainChkData(
res,
form.getValues("chckYr")
);
if (excelData.issues && excelData.issues.length > 0) {
excelData.issues.some((err, index) => {
showConfirmToast(err);
return index === 4; // true 반환 시 반복 종료
});
clearFile();
} else {
setExcelData(excelData.rainChkgdData);
}
})
.finally(() => {
setRainChkLoading(false);
});
} else if (type === "RST") {
filePickedArray(file, 0).then((res) => {
let issues: string[] = [];
if (res && res?.length > 1) {
const guideData = excelToRswtGuideData(
res[0],
form.getValues("chckYr")
form.getValues("chckYr"),
issues
);
const polutionData = excelToRswtPolution(res[1]);
const polutionData = excelToRswtPolution(res[1], issues);
const keyGenerator = (item: rswtChkZodType) =>
`${item.bdstRuseFcltSn}|${item.chckYmd}|${item.utztnUsgCd}`;
const totalData: rswtChkZodType[] = guideData.map((guide) => {
const fusion = polutionData.find(
(polution) =>
guide.bdstRuseFcltSn === polution.bdstRuseFcltSn &&
guide.chckYmd === polution.chckYmd &&
guide.utztnUsgCd === polution.utztnUsgCd
issues = [...guideData.issues, ...polutionData.issues];
if (issues && issues.length > 0) {
issues.some((err, index) => {
showConfirmToast(err);
return index === 6; // true 반환 시 반복 종료
});
clearFile();
} else {
const keyGenerator = (item: rswtChkZodType) =>
`${item.bdstRuseFcltSn}|${item.chckYmd}|${item.utztnUsgCd}`;
const totalData: rswtChkZodType[] = guideData.data.map(
(guide) => {
const fusion = polutionData.data.find(
(polution) =>
guide.bdstRuseFcltSn === polution.bdstRuseFcltSn &&
guide.chckYmd === polution.chckYmd &&
guide.utztnUsgCd === polution.utztnUsgCd
);
if (fusion) {
return {
...guide,
rswtrPollutions: fusion?.rswtrPollutions,
rswtrDetails: fusion?.rswtrDetails,
};
} else {
return {
...guide,
};
}
}
);
const guideKey = new Set(guideData.data.map(keyGenerator));
const onlypolution = polutionData.data.filter(
(item) => !guideKey.has(keyGenerator(item))
);
if (fusion) {
return {
...guide,
rswtrPollutions: fusion?.rswtrPollutions,
rswtrDetails: fusion?.rswtrDetails,
};
} else {
return {
...guide,
};
}
});
const listTotalData: rswtChkZodType[] = [
...totalData,
...onlypolution,
];
const guideKey = new Set(guideData.map(keyGenerator));
const onlypolution = polutionData.filter(
(item) => !guideKey.has(keyGenerator(item))
);
const listTotalData: rswtChkZodType[] = [
...totalData,
...onlypolution,
];
setExcelRswtData(listTotalData);
setExcelRswtData(listTotalData);
}
}
});
}
@@ -165,9 +196,12 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
return;
} else {
rainChkExcelDataUPload(excelData as rainChkZodType[] , form.getValues("chckYr")) ;
setIsRegExcel(false)
setYearChange(form.getValues("chckYr"))
rainChkExcelDataUPload(
excelData as rainChkZodType[],
form.getValues("chckYr")
);
setIsRegExcel(false);
setYearChange(form.getValues("chckYr"));
}
} else if (type === "RST") {
if (excelRswtData === undefined || excelRswtData?.length === 0) {
@@ -176,12 +210,11 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
return;
} else {
rswtChkExceDataUpload(excelRswtData as rswtChkZodType[]);
setIsRegExcel(false)
setYearChange(form.getValues("chckYr"))
}
setIsRegExcel(false);
setYearChange(form.getValues("chckYr"));
}
}
};
return (
<>
@@ -231,14 +264,15 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
<FormUi label="점검결과 파일">
<div className="space-y-4 p-4">
<Input
ref={fileInputRef}
type="file"
onChange={(file) =>{
handleFileChange( file)
////TODO : 폼 을 써야하는 지 확인 필요
console.log(field.value)
} }
onChange={(file) => {
handleFileChange(file);
////TODO : 폼 을 써야하는 지 확인 필요
console.log(field.value);
}}
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
/>
/>
</div>
</FormUi>
)}
@@ -238,26 +238,26 @@ export default function ChkgdModal({ type, obj, setIsModal }: { type: string; ob
<>
<div>
<div>
<Title
title={
type === "RNB"
? "빗물이용시설 " + "지도점검 결과등록"
: "중수도 이용시설 " + "지도점검 결과등록"
}
></Title>
</div>
<div className="flex justify-between">
<div className="flex justify-between">
<Title
title={
type === "RNB"
? "빗물이용시설 " + "지도점검 결과등록"
: "중수도 이용시설 " + "지도점검 결과등록"
}
></Title>
{!rainChkSttn.isSttn ? (
<Button className="mt-8 mr-7" onClick={allDataUpdate}>
저장
</Button>
) : (
<></>
)}
</div>
<h3 className="text-2xl font-bold text-gray-900 mt-2 ml-6">
{type === "RNB"
? `(${obj.bdstNm})` : `(${obj.building.bdstNm})`}
</h3>
{!rainChkSttn.isSttn ? (
<Button className="" onClick={allDataUpdate}>
저장
</Button>
) : (
<></>
)}
</div>
<ScrollArea className="h-[60vh]">
@@ -14,12 +14,12 @@ export default function DrgtDetailModal({
data: customDrgt[];
}) {
// const [isSggNm, setIsSggNm] = useState('')
const [excelData, setExcelData] = useState<any[]>();
// const [isSggNm, setIsSggNm] = useState('')
const [excelData, setExcelData] = useState<any[]>();
const excelClick = () => {
downloadExcel({
data: excelData ?? [],
fileName: "우리동네가뭄 상세현황",
fileName: `우리동네가뭄 상세현황 - ${data[0]?.sggNm}`,
sheetNameArray: ["Sheet1"],
headerRange: "A1:C1"
})
@@ -36,10 +36,10 @@ export default function DrgtDetailModal({
}
}) : [];
setExcelData(exData)
// if(data&&data[0].sggNm){
////TODO: data.sggNm [0[인지 data.sggNm 인지 사용하는지 확인필요
// setIsSggNm(data[0].sggNm)
// }
// if(data&&data[0].sggNm){
////TODO: data.sggNm [0[인지 data.sggNm 인지 사용하는지 확인필요
// setIsSggNm(data[0].sggNm)
// }
}, [data])
return (
@@ -47,7 +47,7 @@ export default function DrgtDetailModal({
<div className="grid grid-cols-4 gap-4 h-full">
<div className="col-span-4">
<div className="flex items-center justify-between">
<Title title={`우리동네가뭄 상세내용 - ${data[0]&&data[0].sggNm ?data[0].sggNm:'' }`} />
<Title title={`우리동네가뭄 상세내용 - ${data[0] && data[0].sggNm ? data[0].sggNm : ''}`} />
<div className="flex flex-row space-x-2">
<Button
size={"sm"}
@@ -65,15 +65,11 @@ export default function DrgtDetailModal({
<ScrollArea className="h-[63vh]">
<UiTable
headName={undefined}
tableData={data }
tableData={data}
headlist={drgtDetailHeadListExport}
pageSize={10}
total={10000}
cellClick={(index: number | undefined, headId: string) => {
console.log(' indx ' , index)
console.log(' headId ' , headId)
}}
pageSize={0}
total={0}
cellClick={undefined}
onPageChange={() => { }}
></UiTable>
</ScrollArea>
@@ -42,7 +42,7 @@ export function PbnstRegModal({
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]);
@@ -72,8 +72,9 @@ export function PbnstRegModal({
</h1>
<div className="border-t border-gray-300 my-4"></div>
<ScrollArea className="h-[75vh]">
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
<div className="flex justify-between items-center">
<TabsList className="">
<TabsTrigger className="!text-xl" value="mng">
시설정보
@@ -81,14 +82,17 @@ export function PbnstRegModal({
<TabsTrigger className="!text-xl" value="buse">
차수별정보
</TabsTrigger>
<Button
onClick={form.handleSubmit(onSubmit, onInvalid)}
size={"sm"}
className="!justify-end"
>
저장
</Button>
</TabsList>
<Button
onClick={form.handleSubmit(onSubmit, onInvalid)}
size={"sm"}
className="mr-5 mt-2"
>
저장
</Button>
</div>
<ScrollArea className="h-[75vh]">
<TabsContent className="max-h-full" value="mng">
<PbnstMngForm
form={form}
@@ -106,8 +110,8 @@ export function PbnstRegModal({
formType={"reg"}
/>
</TabsContent>
</Tabs>
</ScrollArea>
</ScrollArea>
</Tabs>
</>
);
}
@@ -326,7 +326,7 @@ export function PbnstSttnModal({ data, titleVisible }: { data: customPbnst; titl
<ScrollArea className="h-[60vh]">
<div className="card-header">
<h3 className="text-2xl font-medium text-label">
{"하수처리수재이용 실적(m3) 등록결과"}
{"하수처리수재이용 실적(m³) 등록결과"}
</h3>
</div>
<Table variant="secondary">
+84 -41
View File
@@ -1,9 +1,9 @@
import { NextRequest, NextResponse } from "next/server";
import { CS_URL } from "./components/lib/config";
//import { CLAIM_NAME, AUTH_USER_ID } from "./src/shared/config";
import { CLAIM_NAME, AUTH_USER_ID } from "./src/shared/config";
const CLAIM_NAME = "Authorization";
const AUTH_USER_ID = "token-id";
// const CLAIM_NAME = "Authorization";
// const AUTH_USER_ID = "token-id";
const serverApiUrl = CS_URL;
const GEOSERVER_URL = process.env.NEXT_PUBLIC_GEOSERVER_URL || "";
const LX_GEOSERVER_URL = process.env.NEXT_PUBLIC_LX_GEOSERVER_URL || "";
@@ -14,29 +14,54 @@ export function middleware(req: NextRequest) {
console.log(`[Middleware] Request URL: ${req.url}`);
const searchParams = req.nextUrl.searchParams;
// if (pathname.startsWith("/server")) {
// const queryParams = searchParams.toString();
// const newUrl = `${serverApiUrl}${pathname.replace("/server", "")}${
// queryParams ? `?${queryParams}` : ""
// }`;
// console.log(`[Middleware] Rewriting from '/server' path to: ${newUrl}`);
// return NextResponse.rewrite(new URL(newUrl));
// }
if (pathname.startsWith("/server")) {
const queryParams = searchParams.toString();
const decodedParams = Array.from(searchParams.entries())
.map(([key, value]) => `${key}=${decodeURIComponent(value)}`)
.join("&");
const newUrl = `${serverApiUrl}${pathname.replace("/server", "")}${
queryParams ? `?${queryParams}` : ""
decodedParams ? `?${decodedParams}` : ""
}`;
console.log(`[Middleware] Rewriting from '/server' path to: ${newUrl}`);
return NextResponse.rewrite(new URL(newUrl));
}
if (pathname === "/") {
console.log(" maim 화면이동 ");
return NextResponse.redirect(new URL("/map/mainMap", req.url));
}
if (pathname.startsWith("/cms-service")) {
const requestHeaders = new Headers(req.headers);
const Authorization = req.cookies.get(CLAIM_NAME)?.value;
const newUrl = `${serverApiUrl}${pathname}`;
console.log("Authorization cms-service ", Authorization);
if (Authorization) requestHeaders.set(CLAIM_NAME, Authorization);
//if (userId) requestHeaders.set(AUTH_USER_ID, userId);
console.log(
`[Middleware] Rewriting from '/cms-service' path to: ${newUrl}`
);
return NextResponse.rewrite(new URL(newUrl), {
headers: requestHeaders,
});
}
if (pathname.startsWith("/attach-service")) {
const requestHeaders = new Headers(req.headers);
const token =
"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJtbmdyWW4iOiJZIiwiZXhwIjoxNzQ4ODQ4NDkxfQ.ZiYpKxAMyyoPuUquxsWxfQbMBzYN4tsa7itZ49_OEsdGvbUUmKzrIV6Or7VVbEjtAqhh7W97nqB5EP6GRzFC9Q";
const userId = "a0ec7a07-752a-4f7f-89a6-854e63d2e3a0";
//const token = req.cookies.get(CLAIM_NAME)?.value;
//const userId = req.cookies.get(AUTH_USER_ID)?.value;
const token = req.cookies.get(CLAIM_NAME)?.value;
const userId = req.cookies.get(AUTH_USER_ID)?.value;
const newUrl = `${serverApiUrl}${pathname}`;
console.log("serverApiUrl ", serverApiUrl);
console.log("pathname ", pathname);
//wr:dev: pathname /attach-service/api/v1/tus/upload/5e60b70a-956e-40c3-be5a-cdd3100bf8ad
//http://dev.onasys.co.kr:8000/attach-service/api/v1/tus/upload/5e60b70a-956e-40c3-be5a-cdd3100bf8ad
if (token) requestHeaders.set(CLAIM_NAME, token);
if (userId) requestHeaders.set(AUTH_USER_ID, userId);
@@ -48,6 +73,18 @@ export function middleware(req: NextRequest) {
});
}
if (pathname.startsWith("/user-service")) {
const requestHeaders = new Headers(req.headers);
const newUrl = `${serverApiUrl}${pathname}`;
console.log(
`[Middleware] Rewriting from '/user-service' path to: ${newUrl}`
);
return NextResponse.rewrite(new URL(newUrl), {
headers: requestHeaders,
});
}
if (pathname.startsWith("/geoserver")) {
let queryParams = searchParams.toString();
const typename = searchParams.get("TYPENAME");
@@ -56,33 +93,31 @@ export function middleware(req: NextRequest) {
let newUrl = `${GEOSERVER_URL}${pathname.replace("/geoserver", "")}${queryParams ? `?${queryParams}` : ""}`;
if (
typename == "hasudo:tb_il_swage_prcs_fclt" //하수처리시설
|| typename == "hasudo:tb_ms_swage_prcs_zone" //하수처리구역
|| typename == "hasudo:tb_ms_sbmrg_dngr_map" //침수위험지도
|| typename == "hasudo:tb_ms_flood_dngr_map" //도시침수지도
typename == "hasudo:tb_il_swage_prcs_fclt" || //하수처리시설
typename == "hasudo:tb_ms_swage_prcs_zone" || //하수처리구역
typename == "hasudo:tb_ms_sbmrg_dngr_map" || //침수위험지도
typename == "hasudo:tb_ms_flood_dngr_map" //도시침수지도
) {
newUrl = `${GEOSERVER_URL}${pathname.replace("/geoserver", "")}${queryParams ? `?${queryParams}` : ""}`;
}
else if (
typename == "hasudo:tb_ms_swage_ppl" //관로
|| typename == "hasudo:tb_ms_swage_mhl" //맨홀
|| typename == "hasudo:tb_ms_swage_pmstn" //펌프장
|| typename == "hasudo:tb_ms_stofcbr" //우수토실
} else if (
typename == "hasudo:tb_ms_swage_ppl" || //관로
typename == "hasudo:tb_ms_swage_mhl" || //맨홀
typename == "hasudo:tb_ms_swage_pmstn" || //펌프장
typename == "hasudo:tb_ms_stofcbr" //우수토실
) {
newUrl = `${LX_GEOSERVER_URL}${pathname.replace("/geoserver", "")}${queryParams ? `?${queryParams}` : ""}`;
}
else if (
typename == "hasudo:om_dt_untrt_swg_rain" //중점우수토실
|| typename == "hasudo:om_wqlt_station" //관측소
|| typename == "hasudo:tb_wr_bdst_ruse_fclt" //재이용시설
|| typename == "hasudo:tb_wr_rnwtr_utztn_fclt" //빗물이용시설
|| typename == "hasudo:tb_wr_rswtr_fclt" //중수도시설
|| typename == "hasudo:tb_wr_htdfl_fclt" //온배수시설
|| typename == "hasudo:tb_wr_ruse_fclt_dmd_co" //수요처
|| typename == "hasudo:tb_wr_tmpr_dmd_co" //잠재수요처
){
} else if (
typename == "hasudo:om_dt_untrt_swg_rain" || //중점우수토실
typename == "hasudo:om_wqlt_station" || //관측소
typename == "hasudo:tb_wr_bdst_ruse_fclt" || //재이용시설
typename == "hasudo:tb_wr_rnwtr_utztn_fclt" || //빗물이용시설
typename == "hasudo:tb_wr_rswtr_fclt" || //중수도시설
typename == "hasudo:tb_wr_htdfl_fclt" || //온배수시설
typename == "hasudo:tb_wr_ruse_fclt_dmd_co" || //수요처
typename == "hasudo:tb_wr_tmpr_dmd_co" //잠재수요처
) {
const url = req.nextUrl.clone();
url.searchParams.set('TYPENAME', typename.replace("hasudo:",""));
url.searchParams.set("TYPENAME", typename.replace("hasudo:", ""));
queryParams = url.searchParams.toString();
newUrl = `${SEWERAGE_API_URL}/v1/map/geometry${queryParams ? `?${queryParams}` : ""}`;
}
@@ -93,8 +128,9 @@ export function middleware(req: NextRequest) {
if (pathname.startsWith("/sewerage-service")) {
const queryParams = searchParams.toString();
const newUrl = `${SEWERAGE_API_URL}${pathname.replace("/sewerage-service/api", "")}${queryParams ? `?${queryParams}` : ""
}`;
const newUrl = `${SEWERAGE_API_URL}${pathname.replace("/sewerage-service/api", "")}${
queryParams ? `?${queryParams}` : ""
}`;
console.log(`[Middleware] Rewriting from '/geoserver' path to: ${newUrl}`);
return NextResponse.rewrite(new URL(newUrl));
}
@@ -103,5 +139,12 @@ export function middleware(req: NextRequest) {
}
export const config = {
matcher: ["/server/:path*", "/attach-service/:path*", "/geoserver/:path*", "/sewerage-service/:path*"],
matcher: [
"/cms-service/:path*",
"/server/:path*",
"/user-service/:path*",
"/attach-service/:path*",
"/geoserver/:path*",
"/sewerage-service/:path*",
],
};
+1
View File
@@ -17,6 +17,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"i18next": "^25.3.2",
"js-cookie": "^3.0.5",
"lucide-react": "^0.474.0",
"moment": "^2.30.1",
"next": "15.1.7",
@@ -0,0 +1,75 @@
import type { LoginService, ILogin } from "../model/login-interface";
import { tokenManager } from "../lib/token-manager";
import {PROXY_HOST, ACCESS_TOKEN, AUTH_USER_ID,SITE_ID, CLAIM_NAME, ENDPOINT, JWT_EXPIRATION_TIME } from "../../../shared/config";
export class LoginApiService implements LoginService {
private static instance: LoginApiService;
private constructor() {}
public static getInstance(): LoginApiService {
if (!LoginApiService.instance) {
LoginApiService.instance = new LoginApiService();
}
return LoginApiService.instance;
}
public async login(payload: ILogin): Promise<void> {
try {
console.log(' ENDPOINT.USER_SERVICE.LOGIN ', ENDPOINT.USER_SERVICE.LOGIN)
const response = await fetch( PROXY_HOST+ ENDPOINT.USER_SERVICE.LOGIN, {
method: "POST",
body: JSON.stringify({
userId: payload.userId,
password: payload.password,
}),
});
// const data = response.headers.get(ACCESS_TOKEN);
const accessToken = response.headers.get(ACCESS_TOKEN);
const tokenId = response.headers.get(AUTH_USER_ID);
if (!accessToken || !tokenId) {
throw new Error("Missing required authentication tokens");
}
tokenManager.setToken(CLAIM_NAME, accessToken)
tokenManager.setToken(AUTH_USER_ID, tokenId)
tokenManager.setToken("site-id-key", SITE_ID)
tokenManager.setupRefreshTimer(
() => this.silentRefresh(),
JWT_EXPIRATION_TIME,
);
} catch (error) {
throw new Error(`Login failed: ${error}`);
}
}
public async silentRefresh(): Promise<void> {
console.log(' silentRefresh ')
try {
const response = await fetch(PROXY_HOST+
`${ENDPOINT.USER_SERVICE.SILENT_REFRESH}`,
{ method: "PUT" },
);
const data = await response.json();
const accessToken = data[ACCESS_TOKEN];
const tokenId = data[AUTH_USER_ID];
if (!accessToken || !tokenId) {
throw new Error("Missing required authentication tokens");
}
tokenManager.setToken(CLAIM_NAME, accessToken);
tokenManager.setToken(AUTH_USER_ID, tokenId);
} catch (error) {
tokenManager.clearAuthToken();
throw new Error(`Silent refresh failed: ${error}`);
}
}
}
export const LoginApi = LoginApiService.getInstance();
+2
View File
@@ -0,0 +1,2 @@
export { LoginApi } from "./api/login-service";
//export { AuthWrapper } from "./lib/auth-wrapper";
@@ -0,0 +1,59 @@
import { AUTH_USER_ID, CLAIM_NAME } from "@/src/shared/config";
import { getCookie, removeCookie, setCookie } from "@/src/shared/lib/cookie";
export class TokenManager {
private static instance: TokenManager;
private refreshTimer: NodeJS.Timeout | null = null;
private constructor() {}
public static getInstance(): TokenManager {
if (!TokenManager.instance) {
TokenManager.instance = new TokenManager();
}
return TokenManager.instance;
}
public getToken(key: string): string | undefined {
return getCookie(key);
}
public setToken(key: string, value: string): void {
setCookie(key, value, {
secure: window.location.protocol === "https:",
sameSite: "lax",
});
}
public removeToken(key: string): void {
removeCookie(key);
}
public setupRefreshTimer(
callback: () => Promise<void>,
expirationTime: number,
): void {
if (this.refreshTimer) {
clearTimeout(this.refreshTimer);
}
this.refreshTimer = setTimeout(() => {
callback().catch((error) => {
console.error("Silent refresh failed:", error);
this.clearAuthToken();
});
}, expirationTime - 60000);
}
public clearAuthToken(): void {
if (this.refreshTimer) {
clearTimeout(this.refreshTimer);
this.refreshTimer = null;
}
this.removeToken(CLAIM_NAME);
this.removeToken(AUTH_USER_ID);
}
}
export const tokenManager = TokenManager.getInstance();
@@ -0,0 +1,9 @@
export interface ILogin {
userId: string;
password: string;
}
export interface LoginService {
login(payload: ILogin): Promise<void>;
silentRefresh(): Promise<void>;
}
+56
View File
@@ -0,0 +1,56 @@
import { PROXY_HOST } from "./env";
export const BASE_URL = `${PROXY_HOST}`;
export const ENDPOINT = {
ATTACH_SERVICE: {
TUS_UPLOAD: "/attach-service/api/v1/tus/upload",
EDITOR_UPLOAD: "/attach-service/api/v1/upload/editor",
IMAGES: "/attach-service/api/v1/images",
MOVIE_THUMBNAIL: "/attach-service/api/v1/movie/thumbnail",
ATTACHMENTS: "/attach-service/api/v1/atfl/attachments",
DOWNLOAD: "/attach-service/api/v1/atflcd/download",
STREAM_VIDEO: "/attach-service/api/v1/stream/video",
},
USER_SERVICE: {
LOGIN: "/user-service/login",
USERS: "/user-service/api/v1/users",
SILENT_REFRESH: "/user-service/api/v1/users/token/refresh",
AUTHORIZATIONS: "/user-service/api/v1/authorizations",
ROLE_AUTHORIZATIONS: "/user-service/api/v1/role-authorizations",
ROLES: "/user-service/api/v1/roles",
},
CMS_SERVICE: {
SITES: "/cms-service/api/v1/sites",
IPS: "/cms-service/api/v1/site-ips",
DOMAINS: "/cms-service/api/v1/site-dmns",
POSTINGS: "/cms-service/api/v1/site-pstgs",
CODE: "/cms-service/api/v1/code/cache",
MENUS: "/cms-service/api/v1/menus",
MENU_ROLES: "/cms-service/api/v1/menu-roles",
MENU_AUTHRTS: "/cms-service/api/v1/menu-authrts",
CONTENTS: "/cms-service/api/v1/contents",
CONTENTS_DETAILS: "/cms-service/api/v1/contents-details",
ORGANIZATIONS: "/cms-service/api/v1/ognzs",
USER_ORGANIZATION: "/cms-service/api/v1/user-ognz",
IMAGES: "/cms-service/api/v1/images",
BANNERS: "/cms-service/api/v1/bnrs",
TEMPLATE: "/cms-service/api/v1/tmplt",
TERMS: "/cms-service/api/v1/trms",
LWPO_CODE: "/cms-service/api/v1/lwpo-cds",
UP_CODE: "/cms-service/api/v1/up-codes",
POPUPS: "/cms-service/api/v1/popups",
SCHEDULES: "/cms-service/api/v1/schdls",
SURVEY: "/cms-service/api/v1/srvy",
SURVEY_QUESTION: "/cms-service/api/v1/srvy-qitem",
SURVEY_ARTICLE: "/cms-service/api/v1/srvy-artcl",
},
BOARD_SERVICE: {
BBS: "/board-service/api/v1/bbs",
BBS_TEMPLATES: "/board-service/api/v1/bbsTmplt",
POSTS: "/board-service/api/v1/posts",
POSTS_COMMENTS: "/board-service/api/v1/posts-cmnts",
},
};
export const JWT_EXPIRATION_TIME = 1800000;
+15
View File
@@ -0,0 +1,15 @@
export const SITE_ID = process.env.NEXT_PUBLIC_SITE_ID || "WR";
export const PORT = process.env.NEXT_PUBLIC_PORT || "3001";
export const PROXY_HOST = process.env.NEXT_PUBLIC_PROXY_HOST || `http://localhost:${PORT}`;
export const SERVER_API_URL = process.env.NEXT_PUBLIC_SERVER_API_URL ||'http://con.mind-one.co.kr:11080/api/v1';
export const SERVER_API_FO_URL = process.env.NEXT_PUBLIC_FO_SERVER_API_URL||' http://con.mind-one.co.kr:11082/api/v1';
export const SERVER_API_CS_URL = process.env.NEXT_PUBLIC_CS_SERVER_API_URL||'http://dev.onasys.co.kr:8000';
export const SERVER_API_CS_TUS_URL = process.env.NEXT_PUBLIC_CS_TUS_UPLOAD ||'/attach-service/api/v1/tus/upload'
export const CLAIM_NAME = process.env.NEXT_PUBLIC_CLAIM_NAME || "Authorization";
export const ACCESS_TOKEN = process.env.NEXT_PUBLIC_ACCESS_TOKEN || "access-token";
export const REFRESH_TOKEN =process.env.NEXT_PUBLIC_REFRESH_TOKEN || "refresh-token";
export const AUTH_USER_ID = process.env.NEXT_PUBLIC_AUTH_USER_ID || "token-id";
export const SERVER_SEWERAGE_API_URL = process.env.NEXT_PUBLIC_SEWERAGE_API_URL;
+2
View File
@@ -0,0 +1,2 @@
export * from "./api";
export * from "./env";
+31
View File
@@ -0,0 +1,31 @@
import Cookies from "js-cookie";
export function getCookie(name: string): string | undefined {
if (typeof window === "undefined") {
return undefined;
}
return Cookies.get(name);
}
export function setCookie(
name: string,
value: string,
options?: Cookies.CookieAttributes,
): void {
if (typeof window === "undefined") {
return;
}
Cookies.set(name, value, options);
}
export function removeCookie(
name: string,
options?: Cookies.CookieAttributes,
): void {
if (typeof window === "undefined") {
return;
}
Cookies.remove(name, options);
}