diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx index 77dbfb881..5f796a6da 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx @@ -1,7 +1,9 @@ 'use client' import { useWrStore } from "@/app/store"; import type { bdstType, rainRuseType, TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg" +import { BdstReg } from "@/components/ui/form/fcltReg/bdstReg/bdstRegForm"; import { RainRegForm } from "@/components/ui/form/fcltReg/rainReg/component"; +import { BdstRegModal } from "@/components/ui/modal/bdstReg/component"; import { ScrollArea, SearchDiv, SearchInput, UiTable } from "@common/business_components"; import { Button, TableHead, TableRow } from "@common/components"; import { useEffect, useState } from "react"; @@ -55,13 +57,22 @@ export default function Home() { } }, [code,bdstObj]); const cellClick=(val:number)=>{ + let data - if(bdstObj.length>0) { - data =rainRuseObj.filter((item)=> item.bdstInfoFk===val) + if((bdstTable ?? []).length > 0) { + data =rainRuseObj.filter((item)=> item.bdstInfoFk===bdstTable?.[val]?.bdstInfoPk) setRinBdstForm(data) } } - + const divTest =()=>{ + return( + <> + + + + + ) + } return ( <> @@ -75,8 +86,8 @@ export default function Home() {
- - + } /> + {/* */}
diff --git a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstRegForm.tsx b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstRegForm.tsx new file mode 100644 index 000000000..f889cb6c5 --- /dev/null +++ b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstRegForm.tsx @@ -0,0 +1,63 @@ +'use client' +import { headMakeColSpan } from "@/app/ruseFcltMng/fcltReg/rainReg/page"; +import { useWrStore } from "@/app/store"; +import { selectClass, type bdstType } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { SelectBox, UiTable } from "@common/business_components"; +import { Button, Input } from "@common/components"; +import { useEffect, useState } from "react"; + +export function BdstReg(){ + + const { rain, code,init } = useWrStore((state) => { + return state + }); + + const[bdstTable, setbdstTable] = useState (); + const {bdstObj, rainRuseObj } =rain + const getCity =(val:string|number)=>{ + + console.log(val) + } + + const getSgg =(val:string|number)=>{ + + console.log(val) + } + + useEffect ( () => { + if(code.sggCd.length>0){ + const table= bdstObj.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,bdstObj]); + + const cellClick = ()=>{ + + } + const nodeList = headMakeColSpan(rain.upHeadList) + return( + <> +

건축물조회

< h2/> +
+ + + + + +
+
+ + {nodeList} + +
+ + ) +} \ No newline at end of file diff --git a/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx b/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx index 4748e042f..a6dcb71d0 100644 --- a/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx +++ b/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx @@ -1,7 +1,7 @@ "use client"; import { Form, FormField, SelectBox } from "@common/business_components/ui"; -import { Input } from "@common/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"; @@ -33,11 +33,17 @@ export function RainRegForm({data}:{data:rainRuseType[]} ) { const { rain ,code} = useWrStore((state) => state); const {rainFcltCd } = code useEffect(() => { - console.log(data); + console.log("form data:", data); if (data && data.length > 0) { - form.reset(data[0]); // Assuming the first item matches the form schema + const selectedOption = rainFcltCd.find(item => item.val === String(data[0].pntfColKnd)); + const formData = { + ...data[0], + pntfColKnd: selectedOption ? selectedOption.val : "" + }; + console.log("Setting form data:", formData); + form.reset(formData); } - }, [data]); + }, [data, rainFcltCd]); const form = useForm>({ resolver: zodResolver(formSchema), @@ -60,6 +66,14 @@ export function RainRegForm({data}:{data:rainRuseType[]} ) { }, }); + // form 값이 변경될 때마다 로그 출력 + useEffect(() => { + const subscription = form.watch((value) => { + console.log("form values changed:", value); + }); + return () => subscription.unsubscribe(); + }, [form]); + // 2. Define a submit handler. function onSubmit(values: z.infer) { // Do something with the form values. @@ -76,8 +90,9 @@ export function RainRegForm({data}:{data:rainRuseType[]} ) {
{/*
*/}
-
-

○ 빗물이용시설 운영정보

+
+

○ 빗물이용시설 운영정보

+

@@ -94,7 +109,7 @@ export function RainRegForm({data}:{data:rainRuseType[]} ) { className="" type="date" onChange={(e) => field.onChange(e.target.value ? new Date(e.target.value) : undefined)} - value={field.value ? field.value.toISOString().split('T')[0] : ""} + value={field.value ? field?.value.toString().split('T')[0] : ""} /> )} @@ -138,8 +153,12 @@ export function RainRegForm({data}:{data:rainRuseType[]} ) { selectClass={selectClass} label={""} selectArray={rainFcltCd} - onSelectValue={onSelectValue} - {...field} + onSelectValue={(val) => { + field.onChange(val); + onSelectValue(val); + }} + value={field.value} + defaultValue={field.value} /> )} diff --git a/apps/wr/components/ui/modal/bdstReg/component.tsx b/apps/wr/components/ui/modal/bdstReg/component.tsx new file mode 100644 index 000000000..bef2873af --- /dev/null +++ b/apps/wr/components/ui/modal/bdstReg/component.tsx @@ -0,0 +1,33 @@ +import { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@common/components"; + + +type ModalType={ + bodyClass:string + butNm:string + title:string + body:React.ReactNode +} +export function BdstRegModal({bodyClass,butNm,title ,body}:ModalType ) { + return ( + <> + + + + + + + {title} + + + + {body} + + + + + + + + + ); +} diff --git a/apps/wr/components/ui/modal/pbnstMng/component.tsx b/apps/wr/components/ui/modal/pbnstMng/component.tsx index ae3b69246..3dcf3d3b1 100644 --- a/apps/wr/components/ui/modal/pbnstMng/component.tsx +++ b/apps/wr/components/ui/modal/pbnstMng/component.tsx @@ -15,6 +15,8 @@ export function PbnstMngModal(butNm:string,chldrn:React.ReactNode) { {chldrn} + +