type 에러 정리.

This commit is contained in:
truthwing
2025-04-01 13:11:49 +09:00
parent b8d93f1b8b
commit 54f47afaee
3 changed files with 162 additions and 167 deletions
@@ -1,65 +1,88 @@
'use client'
"use client";
import { useWrStore } from "@/app/store";
import type { RainyInfoResponse, TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"
import type {
RainyBuilding,
TableUpperProps,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { RainRegForm } from "@/components/ui/form/fcltReg/rainReg/component";
import { BdstReg } from "@/components/ui/modal/bdstReg/component";
import { ContentsDiv, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, Title, UiModal, UiTable } from "@common/business_components";
import {
ContentsDiv,
ScrollArea,
SearchDiv,
SearchFormLeft,
SearchFormRight,
SearchInput,
Title,
UiModal,
UiTable,
} from "@common/business_components";
import ListDiv from "@common/business_components/ui/list_div";
import { Button, TableHead, TableRow } from "@common/components";
import { useEffect, useState } from "react";
import { useEffect, useState } from "react";
export const headMakeColSpan = (upHeadList: TableUpperProps[]) => {
return (<>
<TableRow>{
upHeadList.map((head: TableUpperProps) =>
(!head.upSequnce ? <TableHead rowSpan={2} key={head.id}>{head.title}</TableHead> :
head.upName === 'upChangeRe' && head.upSequnce === 1 ? <TableHead key={head.id} rowSpan={1} colSpan={3}>{'중축 개축 증축 '}</TableHead> : null))}
</TableRow>
<TableRow>
{upHeadList.map((head: TableUpperProps) =>
(head.upName === 'upChangeRe' ? <TableHead key={head.id}>{head.title}</TableHead> : null))}
</TableRow>
</>)
}
return (
<>
<TableRow>
{upHeadList.map((head: TableUpperProps) =>
!head.upSequnce ? (
<TableHead rowSpan={2} key={head.id}>
{head.title}
</TableHead>
) : head.upName === "upChangeRe" && head.upSequnce === 1 ? (
<TableHead key={head.id} rowSpan={1} colSpan={3}>
{"중축 개축 증축 "}
</TableHead>
) : null
)}
</TableRow>
<TableRow>
{upHeadList.map((head: TableUpperProps) =>
head.upName === "upChangeRe" ? (
<TableHead key={head.id}>{head.title}</TableHead>
) : null
)}
</TableRow>
</>
);
};
export default function Home() {
const { rain, code,init } = useWrStore((state) => {
return state
const { rain, code, init } = useWrStore((state) => {
return state;
});
const {bdstObj, rainRes } =rain
const [rainForm, setRainForm] = useState <RainyInfoResponse> ();
const [bdstTable, setbdstTable] = useState <RainyInfoResponse[]> ();
const { rainRes } = rain;
const [rainForm, setRainForm] = useState<RainyBuilding>();
const [bdstTable, setbdstTable] = useState<RainyBuilding[]>();
const nodeList = headMakeColSpan(rain.upHeadList);
useEffect(() => {
if (!rain.isInit) {
if (!rain.isInit) {
init();
}
}, [rain.isInit,init]);
useEffect ( () => {
if(code.sggCd.length>0){
const table = rainRes.map((item) => {
const sggText= code.sggCd.find((cd)=>cd.val.toString() === item.sggCd )?.text;
const cityText= code.cityCd.find((cd)=>cd.val.toString() === item.ctpvCd )?.text;
return(
{...item,
sggText:sggText,
cityText:cityText
})
})
setbdstTable(table)
}
}, [code,rainRes]);
const cellClick: (val: number ) => void = (val) => {
if((bdstTable ?? []).length > 0) {
setRainForm(rainRes[val])
}
}
}, [rain.isInit, init]);
useEffect(() => {
if (code.sggCd.length > 0) {
const table = rainRes.map((item) => {
const sggText = code.sggCd.find(
(cd) => cd.val.toString() === item.sggCd
)?.text;
const cityText = code.cityCd.find(
(cd) => cd.val.toString() === item.ctpvCd
)?.text;
return { ...item, sggText: sggText, cityText: cityText };
});
setbdstTable(table);
}
}, [code, rainRes]);
const cellClick: (val: number | undefined) => void = (val) => {
if ((bdstTable ?? []).length > 0 && val !== undefined) {
{
setRainForm(rainRes[val]);
}
}
};
return (
<>
@@ -73,7 +96,7 @@ export default function Home() {
className="col-span-3 my-7"
label="건물명"
textValue={""}
setText={function (val: string): void {
setText={function (): void {
throw new Error("Function not implemented.");
}}
/>
@@ -1,7 +1,6 @@
import { bdstUsgCd, comCodeStateExport } from "@/app/store/common/code";
import { getFectch, postFectch, putFectch } from "@/components/lib/api";
export type RainyInfoResponse = {
export type RainyBuilding = {
ctpvCd: string;
sggCd: string;
bdstNm: string;
@@ -10,37 +9,37 @@ export type RainyInfoResponse = {
archArea: string;
archChgArea: string;
bdstInfoPk: number;
reuseBuilding:reuseBuilding
reuseBuilding: reuseBuilding[];
};
export type reuseBuilding= Array<{
lawTrgtYn: string;
bdstUsgCd: string;
export type reuseBuilding = {
lawTrgtYn: string|undefined;
bdstUsgCd: string|undefined;
bdstRuseFcltPk: number;
bdstInfoFk: number;
operMngCd: number ;
anlOperCst: number ;
instlCmptnDt: Date ;
instlCst: number ;
archChgPrmsnDt: string ;
instlCstSprtYn: string ;
instlCstSprtAmt: number
grntchBdstCertYn: string
grntchBdstCertNo: string
grntchBdstCertGrd: string
grntchBdstCertYr: string
rainyObj:rainyObj| null
}>;
export type rainyObj= {
bdstReuseFcltFk:number
pntfColKnd: string | undefined
pntfColArea: number | undefined
dtfcltCpct:number
filtrTrtmfctCpct: number | undefined
filtrTrtmfctYn: string| undefined
filtrTrtmfctPrs: string | undefined
annRnwtQty:number
oilqMeasMthd:string| undefined
operMngCd: number;
anlOperCst: number;
instlCmptnDt: Date;
instlCst: number|undefined;
archChgPrmsnDt: string;
instlCstSprtYn: string|undefined;
instlCstSprtAmt: number|undefined;
grntchBdstCertYn: string|undefined;
grntchBdstCertNo: string|undefined;
grntchBdstCertGrd: string|undefined;
grntchBdstCertYr: string|undefined;
rainyObj: rainyObj | null;
};
export type rainyObj = {
bdstReuseFcltFk: number;
pntfColKnd: string | undefined;
pntfColArea: number | undefined;
dtfcltCpct: number;
filtrTrtmfctCpct: number | undefined;
filtrTrtmfctYn: string | undefined;
filtrTrtmfctPrs: string | undefined;
annRnwtQty: number;
oilqMeasMthd: string | undefined;
};
export type TableUpperProps = {
@@ -50,21 +49,6 @@ export type TableUpperProps = {
upSequnce?: number;
};
// export type bdstType = {
// ctpvCd: string; // 시도
// sggCd: string; // 시군구
// daddr: string; // 위치
// bdstUsgCd: string; // 건축물용도
// frstArchPrmsnDt: string; // 최초건축허가일
// archArea: string; // 건축면적
// lawTrgtYn: string; // 법적의무대상여부
// archChgPrmsnDt: string; // 건축변경 허가일시
// archChgArea: string; // 변경 면적
// bdstInfoPk: number;
// bdstNm: string;
// };
export const upHeadList: TableUpperProps[] = [
{ id: "cityText", title: "시도" },
{ id: "sggText", title: "시군구" },
@@ -72,17 +56,14 @@ export const upHeadList: TableUpperProps[] = [
{ id: "daddr", title: "위치" },
{ id: "bdstUsgCd", title: "건축물용도" },
{ id: "frstArchPrmsnDt", title: "최초건축허가일" },
{ id: "archArea", title: "건축면적", },
{ id: "lawTrgtYn", title: "법적의무대상여부", },
{ id: "archArea", title: "건축면적" },
{ id: "lawTrgtYn", title: "법적의무대상여부" },
{ id: "archChgYn", title: "여부", upName: "upChangeRe", upSequnce: 1 },
{ id: "archChgPrmsnDt", title: "허가일", upName: "upChangeRe", upSequnce: 2 },
{ id: "archChgArea", title: "면적", upName: "upChangeRe", upSequnce: 3 },
];
const rainRes: RainyInfoResponse[] = []
const bdstObj: bdstType[] =[]
const rainRuseObj: rainRuseBd[] = []
const rainRes: RainyBuilding[] = [];
export type selectArray = {
text: string;
@@ -98,29 +79,24 @@ export type rainFacState = {
rain: {
isInit: boolean;
upHeadList: TableUpperProps[];
rainRuseObj: rainRuseBd[];
bdstObj: bdstType[];
selectYN: selectArray[];
rainRes:RainyInfoResponse[];
rainRes: RainyBuilding[];
};
};
type rainFacSActions = {
init: () => void;
dataInit: () => void;
rainReg: (data: RainyInfoResponse) => void;
rainUpdate: (data: RainyInfoResponse) => void;
rainReg: (data: RainyBuilding) => void;
rainUpdate: (data: RainyBuilding) => void;
};
export type rainFacType = rainFacState & rainFacSActions;
export const rainFacStateExport: rainFacState = {
rain: {
isInit: false,
rainRes:rainRes,
rainRes: rainRes,
upHeadList: upHeadList,
rainRuseObj: rainRuseObj,
bdstObj: bdstObj,
selectYN: selectYN,
},
};
@@ -129,62 +105,59 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
set: any
) => {
return {
init: async() =>{
init: async () => {
try {
// 파라이터 수정 통합관리자 =0, 시관리자=시코드, 시군구 관리자= 시군구 코드 를 세번째 파라미터로 지정 / 건축물 서치가 있을경우 4번째 파라미터로 던지기 즉 1/20/42(서울시)/영현빌딩 이런식으로)
const rainRes = await getFectch('wr', "/reuseFc/rainyInfoList/1/20/42");
const rainRes = await getFectch("wr", "/reuseFc/rainyInfoList/1/20/42");
// 여기서 상태 업데이트
return set((state: rainFacState) => ({
...state,
rain: {
...state.rain,
rainRes:rainRes,
isInit: false
}
rainRes: rainRes,
isInit: false,
},
}));
} catch (error) {
console.log('error', error);
console.log("error", error);
} finally {
console.log('finally');
console.log("finally");
}
},
dataInit: () =>
set(async (state: rainFacState) => {
console.log(" state ", state.rain.bdstObj)
return ({
console.log(" state ", state.rain);
return {
rain: {
...state.rain,
isInit: false,
},
})
},
};
}),
rainReg:(data:RainyInfoResponse)=>
set(async(state:rainFacState) =>{
try{
const res= postFectch('/reuseFc/rainyInfo' , data)
}catch (e){
alert('등록이 오류입니다.')
}finally{
alert('등록이 완료되었습니다.')
}
rainReg: (data: RainyBuilding) =>
set(async () => {
try {
const res = postFectch("/reuseFc/rainyInfo", data);
console.log("res", res);
} catch (e) {
console.log("e", e);
alert("등록이 오류입니다.");
} finally {
alert("등록이 완료되었습니다.");
}
),
rainUpdate:(data:RainyInfoResponse)=>
set(async(state:rainFacState) =>{
try{
const res= putFectch('/reuseFc/rainyInfo' , data)
}catch (e){
alert('업데이트 오류입니다.')
}finally{
alert('업데이트가 완료되었습니다.')
}
}),
rainUpdate: (data: RainyBuilding) =>
set(async () => {
try {
const res = putFectch("/reuseFc/rainyInfo", data);
console.log("res", res);
} catch (e) {
console.log("e", e);
alert("업데이트 오류입니다.");
} finally {
alert("업데이트가 완료되었습니다.");
}
),
}),
};
};
@@ -1,30 +1,29 @@
"use client";
import { Form, FormField, SelectBox } from "@common/business_components/ui";
import { Button, Input } from "@common/components/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { FormUi } from "@common/business_components";
import { useWrStore } from "@/app/store";
import {
selectClass,
type RainyInfoResponse,
type RainyBuilding,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { useEffect } from "react";
import {
bdstDefZod,
rainDefZod,
rainZod,
} from "@/components/lib/type/zod/fcltReg/controlZod";
import { DatePicker, FormUi } from "@common/business_components";
import { Form, FormField, SelectBox } from "@common/business_components/ui";
import { Button, Input } from "@common/components/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import BdstReg from "../bdstReg/component";
import { DatePicker } from "@common/business_components";
export function RainRegForm({
rainForm,
isModal,
}: {
rainForm: RainyInfoResponse | undefined;
rainForm: RainyBuilding | undefined;
isModal: boolean;
}) {
const formSchema = z.object(rainZod);
@@ -40,7 +39,7 @@ export function RainRegForm({
},
});
const { rain, code, rainReg, rainUpdate, init } = useWrStore(
const { code, rainReg, rainUpdate, init } = useWrStore(
(state) => state
);
const { rainFcltCd } = code;
@@ -112,31 +111,31 @@ export function RainRegForm({
oilqMeasMthd: rainObj?.oilqMeasMthd,
};
regRainForm.reuseBuilding[0] = {
...rainForm.reuseBuilding[0],
...rainForm?.reuseBuilding[0],
instlCmptnDt: raw.instlCmptnDt,
instlCst: raw.instlCst || rainForm.reuseBuilding[0]?.instlCst,
instlCst: raw.instlCst || rainForm?.reuseBuilding[0]?.instlCst,
instlCstSprtYn:
raw.instlCstSprtYn || rainForm.reuseBuilding[0]?.instlCstSprtYn,
raw.instlCstSprtYn || rainForm?.reuseBuilding[0]?.instlCstSprtYn,
instlCstSprtAmt:
raw.instlCstSprtAmt || rainForm.reuseBuilding[0]?.instlCstSprtAmt,
raw.instlCstSprtAmt || rainForm?.reuseBuilding[0]?.instlCstSprtAmt,
grntchBdstCertYn:
raw.grntchBdstCertYn || rainForm.reuseBuilding[0]?.grntchBdstCertYn,
raw.grntchBdstCertYn || rainForm?.reuseBuilding[0]?.grntchBdstCertYn,
grntchBdstCertYr:
raw.grntchBdstCertYr || rainForm.reuseBuilding[0]?.grntchBdstCertYr,
raw.grntchBdstCertYr || rainForm?.reuseBuilding[0]?.grntchBdstCertYr,
grntchBdstCertNo:
raw.grntchBdstCertNo || rainForm.reuseBuilding[0]?.grntchBdstCertNo,
raw.grntchBdstCertNo || rainForm?.reuseBuilding[0]?.grntchBdstCertNo,
grntchBdstCertGrd:
raw.grntchBdstCertGrd || rainForm.reuseBuilding[0]?.grntchBdstCertGrd,
bdstUsgCd: raw.bdstUsgCd || rainForm.reuseBuilding[0]?.bdstUsgCdd,
lawTrgtYn: raw.lawTrgtYn || rainForm.lawTrgtYn,
raw.grntchBdstCertGrd || rainForm?.reuseBuilding[0]?.grntchBdstCertGrd,
bdstUsgCd: raw.bdstUsgCd || rainForm?.reuseBuilding[0]?.bdstUsgCd,
lawTrgtYn: raw.lawTrgtYn || rainForm?.reuseBuilding[0]?.lawTrgtYn,
};
}
if (isModal) {
rainReg(regRainForm);
rainReg(raw);
} else {
rainUpdate(regRainForm);
rainUpdate(raw);
}
init();