diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index 13a71263e..e2d54d6f8 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -173,7 +173,7 @@ export default function PbnstSttn() {
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx index 8dd2a4d6f..ad2223473 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx @@ -136,7 +136,7 @@ export const rainSttHeadListExport: z.infer = [ export const rainSttNodeListExport: CommonTableProps[] = [ { id: "bdnstInfo", - title: "1.건축물정보", + title: "건축물정보", visible: true, row: 1, rowSpan: 1, @@ -144,7 +144,7 @@ export const rainSttNodeListExport: CommonTableProps[] = [ }, { id: "rainFcltInfo", - title: "2.빗물이용시설정보", + title: "빗물이용시설정보", visible: true, row: 1, rowSpan: 1, @@ -152,7 +152,7 @@ export const rainSttNodeListExport: CommonTableProps[] = [ }, { id: "insenInfo", - title: "3.인센티브 정보", + title: "인센티브 정보", visible: true, row: 1, rowSpan: 1, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx index 804617ad8..9989290e7 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx @@ -130,7 +130,7 @@ export const rswtSttHeadListExport: z.infer = [ export const rswtSttNodeListExport: CommonTableProps[] = [ { id: "bdnstInfo", - title: "1.건축물정보", + title: "건축물정보", visible: true, row: 1, rowSpan: 1, @@ -138,7 +138,7 @@ export const rswtSttNodeListExport: CommonTableProps[] = [ }, { id: "rswtFcltInfo", - title: "2.중수도시설정보", + title: "중수도시설정보", visible: true, row: 1, rowSpan: 1, @@ -146,7 +146,7 @@ export const rswtSttNodeListExport: CommonTableProps[] = [ }, { id: "insenInfo", - title: "3.인센티브 정보", + title: "인센티브 정보", visible: true, row: 1, rowSpan: 1, diff --git a/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx b/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx index 83a5a3523..4b3c8aa75 100644 --- a/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx +++ b/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx @@ -1,5 +1,5 @@ import { useWrStore } from "@/app/store"; -import { sttnHeadListType } from "@/app/store/ruseFcltMng/fcltSttn/rainSttn/headList"; +import { sttnHeadListType } from "@/app/store/ruseFcltMng/fcltSttn/rainSttn/headList"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@common/business_components/ui"; import { Button, Checkbox } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -7,33 +7,54 @@ import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; -export default function HeadChModal({headList, type }:{headList : z.infer ,type:string }) { - const { rainChSttnHead , rswtChSttnHead, htdflChSttnHead, pbnstChSttnHead} = useWrStore((state) => state); - - - let items = headList.map(item => ({id:item.id, title:item.title, val:item.visible })); - - - const form = useForm>({ - resolver: zodResolver(sttnHeadListType), - defaultValues: [], - }) +export default function HeadChModal({ headList, type }: { headList: z.infer, type: string }) { + const { rainChSttnHead, rswtChSttnHead, htdflChSttnHead, pbnstChSttnHead } = useWrStore((state) => state); - useEffect(() =>{ - form.reset(headList) + let items = headList.map(item => ({ id: item.id, title: item.title, val: item.visible })); - },[headList]) + /*const form = useForm>({ + resolver: zodResolver(sttnHeadListType), + defaultValues: [], + }) - const onSubmit = (valueList : z.infer ) =>{ - if(type==='RNB'){ + + useEffect(() =>{ + form.reset(headList) + + + },[headList])*/ + + const form = useForm>({ + resolver: zodResolver(sttnHeadListType), + defaultValues: headList, + }); + + useEffect(() => { + form.reset(headList); + }, [headList, form]); + + const rawValues = form.watch(); + const values: Array<{ visible: boolean }> = Array.isArray(rawValues) + ? rawValues + : Object.values(rawValues); + + const allChecked = values.every((v) => v.visible); + + const toggleAll = (checked: boolean) => { + const newValues = values.map((v) => ({ ...v, visible: checked })); + form.reset(newValues); + }; + + const onSubmit = (valueList: z.infer) => { + if (type === 'RNB') { rainChSttnHead(valueList) - }else if(type=== 'RST'){ + } else if (type === 'RST') { rswtChSttnHead(valueList) - }else if(type === 'HTB'){ + } else if (type === 'HTB') { htdflChSttnHead(valueList) - }else if(type === 'PBN'){ + } else if (type === 'PBN') { pbnstChSttnHead(valueList) } } @@ -42,42 +63,50 @@ export default function HeadChModal({headList, type }:{headList : z.infer
- - -
-

조회항목 설정

-
- {items.map((item,index) => ( - - { - return ( - - - - { - field.onChange(checked); - return; - } - } - /> - - - {item.title} - - - ); - }} - /> - ))} + + +
+

조회항목 설정

+
+ {/* 전체 선택/해제 체크박스 */} + + + toggleAll(checked as boolean)} + /> + + 전체 + + {items.map((item, index) => ( + { + return ( + + + { + field.onChange(checked); + return; + } + } + /> + + + {item.title} + + + ); + }} + /> + ))}