diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index 93adfb25c..095092a43 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,11 +1,10 @@ "use client" import { Checkbox, Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components"; -import { useEffect, useState } from "react"; +import { useEffect, useState, useRef } from "react"; import { HeadMakeColSpan } from "./HeadMakeColSpan"; import UiPageNations from "./uiPageNations"; -import { AlignVerticalDistributeCenterIcon, Check } from "lucide-react"; -import { boolean } from "zod"; +import { Check } from "lucide-react"; type UiTableProps = { headName: React.ReactNode | undefined; @@ -33,7 +32,8 @@ type UiHeadProps = { export function UiTable({ tableData, headlist, pageSize, total, headName, children, cellClick, onPageChange, className = '', resetPageNo = false, boldArray = [], resetSelection = false, index = -1 }: UiTableProps) { const [cur, setCur] = useState(1); const [idx, setIdx] = useState(index); - const [isCheck, seIsCheck] = useState(false); + const [headerHeight, setHeaderHeight] = useState(0); + const headerRef = useRef(null); useEffect(() => { @@ -55,6 +55,12 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr setIdx(-1); }, [tableData]); + useEffect(() => { + if (headerRef.current) { + setHeaderHeight(headerRef.current.offsetHeight-5); + } + }, [tableData, headlist]); + const handlePageChange = (page: number) => { setCur(page); onPageChange(page); @@ -75,11 +81,11 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr : <>}
- + {children ? children : } - {tableData.length > 0 ? tableData?.map((el: { [key: string]: any }, index) => ( + {tableData.length > 0 ? tableData?.map((el: Record, index) => ( {headlist .filter((item) => item.visible != false) @@ -90,7 +96,8 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr handleCellClick(index, head.id)} key={`cell-${head.id}-${index}`} > @@ -104,7 +111,7 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr handleCellClick(index, head.id)} key={`cell-${head.id}-${index}`} >