diff --git a/apps/fo/next-env.d.ts b/apps/fo/next-env.d.ts new file mode 100644 index 000000000..1b3be0840 --- /dev/null +++ b/apps/fo/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/package.json b/package.json index ae28525c6..5375511be 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "packages/*" ], "scripts": { - "build": "turbo run build --filter=!wr", + "build": "turbo run build", "dev": "turbo run dev", "dev:cs": "turbo run dev --filter=cs", "dev:sn": "turbo run dev --filter=sn", diff --git a/packages/common/business_components/src/ui/chart/BarChart.tsx b/packages/common/business_components/src/ui/chart/BarChart.tsx index b75bf373c..0802a72e4 100644 --- a/packages/common/business_components/src/ui/chart/BarChart.tsx +++ b/packages/common/business_components/src/ui/chart/BarChart.tsx @@ -64,10 +64,10 @@ const CustomLegend = (props: any) => { const { payload } = props; return (
- {payload.map((entry, index: number) => ( + {payload.map((entry: unknown, index: number) => (
-
- {entry.value} +
+ {(entry as {value: string}).value}
))}
@@ -76,7 +76,15 @@ const CustomLegend = (props: any) => { export default function Chart({chartConfig=undefined, chartData=[], chartTitle='차트', chartClassName='w-full h-full', graphSize=40, yFieldText='', showLegend=false} : BarChartProps) { const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEEAD", "#D4A5A5"]; + const getMaxValue = (data: any[], keyPrefix: string) => { + return Math.max(...data.map(item => + Object.keys(item) + .filter(key => key.includes(keyPrefix)) + .map(key => item[key]) + ).flat()); + }; + const barMaxValue = getMaxValue(chartData, 'barVal'); return ( <> {chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( @@ -102,7 +110,8 @@ export default function Chart({chartConfig=undefined, chartData=[], chartTitle=' axisLine={true} fontSize={12} fontWeight={500} - label={yFieldText ? { value: yFieldText, className:"text-[13px] foont-bold", position: 'top', textAnchor: 'middle', offset: 20 } : undefined} + domain={[0, Math.ceil(barMaxValue * 1)]} + label={yFieldText ? { value: yFieldText, className:"text-[13px] font-bold", position: 'insideLeft', angle: -90, offset: 20 } : undefined} /> }/> {chartData && chartData.length > 0 && ( diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index a689af8ca..4014702b6 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -113,20 +113,21 @@ export default function Linechart({ }, []); // 데이터의 최대값 계산 - const getMaxValue = (data: ChartDataType, keyPrefix: string) => { - return Math.max(...Object.values(data).map(item => - Object.keys(item) - .filter(key => key.includes(keyPrefix)) - .map(key => item[key] as unknown as number) - ).flat()); + const getMaxValue = (data: ChartDataType): number => { + return Math.max(...Object.values(data).flatMap(dataset => + dataset.map(entry => { + const val = parseFloat(entry.val); + return isNaN(val) ? 0 : val; + }) + )); }; - const lineMaxValue = getMaxValue(chartData, 'lineVal'); + const lineMaxValue = getMaxValue(chartData); return (
{chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( -
+
{chartTitle}
) : null} diff --git a/packages/common/business_components/src/ui/excel/excelStyle.tsx b/packages/common/business_components/src/ui/excel/excelStyle.tsx index 6674720dc..3c8f8d219 100644 --- a/packages/common/business_components/src/ui/excel/excelStyle.tsx +++ b/packages/common/business_components/src/ui/excel/excelStyle.tsx @@ -1,5 +1,6 @@ -import type { sheetParameter } from '@/index'; +// import type { sheetParameter } from '@/index'; import * as XlsxPopulate from '@xlsx/xlsx-populate'; +import type { SheetParameter } from './index'; @@ -38,13 +39,13 @@ export const excelStyle = async (data: ArrayBuffer, range: string = "A1:V3", fil } -export const excelArrayStyle = async (data: ArrayBuffer, range: [typeof sheetParameter], fileNm:string) => { +export const excelArrayStyle = async (data: ArrayBuffer, range: SheetParameter[], fileNm: string) => { const workbook = await XlsxPopulate.Workbook.fromData(data); - if(range){ - range.forEach((item , index)=>{ + if (range) { + range.forEach((item, index) => { const rangeCells = workbook.activeSheet(index)?.sheet(index)?.range(item.headerRange); console.log(rangeCells); - rangeCells?.style((styleQ)=>{ + rangeCells?.style((styleQ) => { makeCellStyle(styleQ) }); diff --git a/packages/common/business_components/src/ui/excel/index.tsx b/packages/common/business_components/src/ui/excel/index.tsx index 76b4ba2f9..96f3b3e5d 100644 --- a/packages/common/business_components/src/ui/excel/index.tsx +++ b/packages/common/business_components/src/ui/excel/index.tsx @@ -5,7 +5,7 @@ type ExcelDownloadProps = { data: JSON | JSON[]; fileName: string; sheetNameArray: string[]; - headerRange: string; + headerRange?: string; } export const downloadExcel = ({ data, fileName = new Date().getTime().toString() + '.xlsx', sheetNameArray = ["Sheet1"], headerRange='A1:V3'}: ExcelDownloadProps) => { @@ -15,17 +15,21 @@ export const downloadExcel = ({ data, fileName = new Date().getTime().toString() excelStyle(XLSX.write(workbook, { bookType: "xlsx", type: "buffer" }), headerRange, fileName); }; -export const sheetParameter ={ - data:[[]], headerNum:0, headerRange:'A1:V3', sheetName:'Sheet1', startCol:0 -} +export type SheetParameter = { + data: any[][]; + headerNum: number; + headerRange: string; + sheetName: string; + startCol?: string; +}; -export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: Array): Promise => { +export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: SheetParameter[]): Promise => { const workbook = XLSX.utils.book_new(); for (let i = 0; i < sheetArray.length; i++) { // Create a new worksheet for each sheet const worksheet = XLSX.utils.aoa_to_sheet(sheetArray[i]?.data || [[]]); // Add data to the worksheet starting from the specified header number - if (sheetArray&&sheetArray[i]?.headerNum) { + if (sheetArray && sheetArray[i]?.headerNum) { XLSX.utils.sheet_add_aoa(worksheet, sheetArray[i]?.data || [[]], { origin: `A${sheetArray[i]?.headerNum}` }); } // Append the worksheet to the workbook with the specified sheet name @@ -37,7 +41,6 @@ export const downloadMultipleExcel = (fileName = new Date().getTime().toString() return Promise.resolve(undefined); }; - export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):Promise =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -80,8 +83,6 @@ export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):P }); } - - export const filePickedArray=(oFile: File, headerNum:number=0):Promise =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -123,8 +124,6 @@ export const filePickedArray=(oFile: File, headerNum:number=0):Promise =>{ // Create A File Reader HTML5 return new Promise(() => { // Ready The Event For When A File Gets Selected @@ -149,28 +148,20 @@ export const filePickedBlob=(oFile: ArrayBuffer, data:[][],fileNm:string, header }); } - export const filePickedBlobArray= (oFile: ArrayBuffer,fileNm:string, sheetArray: [typeof sheetParameter]):Promise =>{ // Create A File Reader HTML5 - return new Promise (async () => { - // Ready The Event For When A File Gets Selected - const wb = XLSX.read(oFile, { type: 'binary' }); - // Loop Over Each Sheet - wb.SheetNames.forEach( function (sheetName, index) { - // Obtain The Current Row As CSV - if(sheetArray[index]){ - const sheet = wb.Sheets[sheetName]; - if (sheet) { - //오리진 확인 test 필요 - // const sheet = XLSX.utils.json_to_sheet(data); - const startCol = sheetArray[index].startCol?sheetArray[index].startCol.toString():'A'; - XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol+sheetArray[index].headerNum }); - // XLSX.utils.book_append_sheet(wb, sheet, 'test'); - } else { - console.error(`Sheet "${sheetName}" is undefined.`); - } - } - }); - - - await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) - }); - } \ No newline at end of file +export const filePickedBlobArray = (oFile: ArrayBuffer, fileNm: string, sheetArray: SheetParameter[]): Promise => { + return new Promise(async () => { + const wb = XLSX.read(oFile, { type: 'binary' }); + wb.SheetNames.forEach(function (sheetName, index) { + if (sheetArray[index]) { + const sheet = wb.Sheets[sheetName]; + if (sheet) { + const startCol = sheetArray[index].startCol ? sheetArray[index].startCol : 'A'; + XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol + sheetArray[index].headerNum }); + } else { + console.error(`Sheet "${sheetName}" is undefined.`); + } + } + }); + await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) + }); +} \ No newline at end of file diff --git a/packages/common/business_components/src/ui/form_ui/index.tsx b/packages/common/business_components/src/ui/form_ui/index.tsx index bd9930c3c..ec1854636 100644 --- a/packages/common/business_components/src/ui/form_ui/index.tsx +++ b/packages/common/business_components/src/ui/form_ui/index.tsx @@ -1,19 +1,64 @@ -import React from "react"; +import React, { useCallback, useState } from "react"; import { FormControl, FormItem, FormLabel, FormMessage } from "../form"; +import { Button, Checkbox } from "@common/components/ui"; -const FormUi = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & {label:string|undefined} ->(({children, label},ref)=>{ +export const BZNM_TOT_NO = '총사업자등록번호'; +export const CANDIDATE = '공급처 후보지 선택(필수아님)'; + +interface FormUiProps extends React.HTMLAttributes { + label?: string; + onCheckboxChange?: (checked: boolean) => void; + isDisabled?: boolean; +} + +interface FormElementProps extends React.HTMLAttributes { + disabled?: boolean; +} + +const FormUi = React.forwardRef( + ({ children, label, onCheckboxChange, isDisabled }, ref) => { + const [isChecked, setIsChecked] = useState(false); + + const handleCheckboxChange = useCallback((checked: boolean) => { + setIsChecked(checked); + onCheckboxChange?.(checked); + }, [onCheckboxChange]); + console.log(children); return ( - - {label?{label}:<>} - - {children} - - - - ) -}) + + {label && {label}} + {label === BZNM_TOT_NO && ( +
+
+ + +
+
+ )} + {label === CANDIDATE && ( + + {children} + + )} + {label !== BZNM_TOT_NO && label !== CANDIDATE && ( + + {React.isValidElement(children) && isDisabled + ? React.cloneElement(children, { + disabled: true, + ...(children.props as FormElementProps) + }) + : children} + + )} + +
+ ); + } +); + FormUi.displayName = 'FormUi'; -export { FormUi }; +export { FormUi }; \ No newline at end of file diff --git a/packages/common/business_components/src/ui/search_base_form/index.tsx b/packages/common/business_components/src/ui/search_base_form/index.tsx index 9dc1bf735..b8d8355ae 100644 --- a/packages/common/business_components/src/ui/search_base_form/index.tsx +++ b/packages/common/business_components/src/ui/search_base_form/index.tsx @@ -1,3 +1,5 @@ +"use client" + import { Button } from "@common/components/ui"; import { useCallback, useEffect, useState } from "react"; import { SearchFormLeft, type EnvPartSelectDataType } from "../search_form_left"; diff --git a/packages/common/business_components/src/ui/search_form_left/index.tsx b/packages/common/business_components/src/ui/search_form_left/index.tsx index ec9e814f5..02112f084 100644 --- a/packages/common/business_components/src/ui/search_form_left/index.tsx +++ b/packages/common/business_components/src/ui/search_form_left/index.tsx @@ -1,4 +1,6 @@ -import React, { useEffect, useState } from 'react'; +"use client" + +import React, { useEffect, useState } from 'react'; import type { SelectDataType } from '../search_input_select'; import { SelectBox } from '../select'; diff --git a/packages/common/business_components/src/ui/search_form_right/index.tsx b/packages/common/business_components/src/ui/search_form_right/index.tsx index fda7eefd6..f5a92dde7 100644 --- a/packages/common/business_components/src/ui/search_form_right/index.tsx +++ b/packages/common/business_components/src/ui/search_form_right/index.tsx @@ -1,8 +1,8 @@ import React from 'react'; -function SearchFormRight(props: {children: React.ReactNode}) { +function SearchFormRight(props: {children: React.ReactNode, className?: string}) { return ( -
+
{props.children}
) diff --git a/packages/common/business_components/src/ui/tab/index.tsx b/packages/common/business_components/src/ui/tab/index.tsx index 9dde67780..aee969460 100644 --- a/packages/common/business_components/src/ui/tab/index.tsx +++ b/packages/common/business_components/src/ui/tab/index.tsx @@ -6,37 +6,41 @@ interface TabItem { label: string; } -interface UITabProps extends React.HTMLAttributes { +interface UITabProps extends Omit, 'dir'> { defaultValue?: string; tabList: TabItem[]; children: React.ReactNode; onValueChange?: (value: string) => void; } -const UITab = React.forwardRef< +const UITab = React.forwardRef< HTMLDivElement, UITabProps ->(({defaultValue, tabList, children, onValueChange, ...props}, ref)=>{ - return ( - - - {tabList.map((tab) => ( - - {tab.label} - - ))} - - {children} - - ) -}) +>(({defaultValue, tabList, children, onValueChange, ...props}, ref) => { + return ( + + + {tabList.map((tab) => ( + + {tab.label} + + ))} + + {children} + + ); +}); + +UITab.displayName = 'UITab'; + export { UITab }; diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index 791eddffe..48f4deb62 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,3 +1,5 @@ +"use client" + import { Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components"; import { useEffect, useState } from "react"; import { HeadMakeColSpan } from "./HeadMakeColSpan";