diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index f4a2230e4..c88385ac6 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,15 +1,14 @@ -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components"; +import { Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components"; import { useEffect, useState } from "react"; -import UiPageNations from "./uiPageNations"; import { HeadMakeColSpan } from "./HeadMakeColSpan"; +import UiPageNations from "./uiPageNations"; type UiTableProps = { headName: React.ReactNode | undefined; - tableData: { [key: string]: string | number | boolean | object}[]; + tableData: { [key: string]:any}[]; headlist: UiHeadProps[]; pageSize: number; total: number; - children: React.ReactNode | undefined; cellClick : ((index:number|undefined, headId:string)=>void )| undefined; onPageChange: (page: number) => void; className?: string; @@ -22,7 +21,7 @@ type UiHeadProps = { align?: string; } -export function UiTable({ tableData, headlist, pageSize, total, children, headName, cellClick, onPageChange, className = '', resetPageNo = false }: UiTableProps) { +export function UiTable({ tableData, headlist, pageSize, total, headName, cellClick, onPageChange, className = '', resetPageNo = false }: UiTableProps) { const [cur, setCur] = useState(1); const [idx, setIdx] = useState(-1); @@ -44,7 +43,8 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa setIdx(index); } }; - + console.log(tableData); + return ( <> {headName ?
@@ -56,24 +56,24 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa - {tableData?.map((el: { [key: string]: string | number | boolean | object}, index) => ( - console.log(index), - + {tableData.length > 0 ? tableData?.map((el: { [key: string]: any}, index) => ( + {headlist?.map((head) => ( - head.id&&head.id.length == 1 ? <> : - handleCellClick(index, head.id)} - key={head.id + index} - > - {typeof el[head.id] === 'number' ? String(el[head.id]).replace(/\B(?=(\d{3})+(?!\d))/g, ",") : String(el[head.id] ?? '')} - + head.id && head.id.length > 1 && ( + handleCellClick(index, head.id)} + key={`cell-${head.id}-${index}`} + > + {typeof el[head.id] === 'number' ? String(el[head.id]).replace(/\B(?=(\d{3})+(?!\d))/g, ",") : String(el[head.id] ?? '')} + + ) ))} - ))} + )) : <>} {total <= 0 ? <> : }