diff --git a/packages/common/business_components/src/form.md b/packages/common/business_components/src/form.md new file mode 100644 index 000000000..4e9b786cf --- /dev/null +++ b/packages/common/business_components/src/form.md @@ -0,0 +1,93 @@ +## form 모듈 + +### 공통 모듈 중 chart를 다양한 테마로 적용시킬 수 있도록 해주는 모듈 + +  1. 폼 모듈 사용법 + +    1-1) 패키지 사용법 + +      (1) zod 사용법 +https://zod.dev/?id=introduction + +    1-2) 호출방법 + +      (1) form에 필요한 Form,FormField,useForm useForm,z, zodResolver import + +```js +import { + Form, + FormField, + SelectBox, +} from "@common/business_components/ui"; +import { 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"; +``` + +      (2)zod 정의 + +```js +const formSchema = z.object({ + facilityName: z.string().min(2).max(50), + instlCmptnDt:z.string(), // FormField 내 name의 타입및 min max 구성 가능 + +}); + + +const form = useForm>({ + resolver: zodResolver(formSchema), + //초기값 세팅 z.object에 등록한 값은 반드시 세팅해야함. + defaultValues: { + facilityName :'', + instlCmptnDt:'', // + + }, + }); + + function onSubmit(values: z.infer) { + // form submit 함수 + console.log(values);// zod.object에 등록하고 form에 구현한 값이 출력됨. + } + + + +``` + +      (3) form구성 + +```js +
+ +
+ ( + + // zod에 등록된 name 값의 폼 객체 생성 + //select box 삽입시 + + + + )} + /> +
+
+ ( + + // zod에 등록된 name 값의 폼 객체 생성 + //input 삽입시 + + + + )} + /> +
+
+ +``` diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index e68459bf0..136034e00 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -76,7 +76,24 @@ const CustomLegend = (props: any) => { ); }; -export default function Linechart(props: { chartConfig: ChartConfig; chartData: any[] | undefined; chartTitle:string}) { +type DataType = {label : string; val:number}; +type ChartDataType = { + chartData1: DataType[]; + chartData2: DataType[]; +}; + +export default function Linechart(props: { chartConfig: ChartConfig; chartData: ChartDataType; chartTitle:string}) { + const mergedData = Object.values(props.chartData).reduce((acc, dataset) => { + dataset.forEach((entry, index) => { + if (!acc[index]) { + acc[index] = { label: entry.label }; // label 추가 + } + const key = Object.keys(props.chartData).find(k => props.chartData[k] === dataset); + if (key) acc[index][key] = entry.val; + }); + return acc; + }, [] as any[]); + return ( @@ -86,13 +103,15 @@ export default function Linechart(props: { chartConfig: ChartConfig; chartData: ): null}
- - + + } /> - + {Object.keys(props.chartData).map((key, index) => ( + + ))}
diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index c96cabe7c..cbb37b273 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,7 +1,6 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components"; import UiPageNations from "./uiPageNations"; - type UiTableProps = { headName: React.ReactNode | undefined; tableData: { [key: string]: string | number | boolean }[]; @@ -9,14 +8,15 @@ type UiTableProps = { pageSize: number; total: number; children: React.ReactNode | undefined; + cellClick : (index:number)=>void | undefined; } type UiHeadProps = { id: string; title: string; - } -export function UiTable({ tableData, headlist, pageSize, total, children, headName }: UiTableProps) { + +export function UiTable({ tableData, headlist, pageSize, total, children, headName, cellClick }: UiTableProps) { const cur = 1; return ( @@ -35,13 +35,11 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa {tableData?.map((el: { [key: string]: string | number | boolean }, index) => ( {headlist.map((head) => ( - {el[head.id]} + cellClick(index)} key={head.id + index}>{el[head.id]} ))} - ))} - {total <= 0 ? <> : }