import { ColumnProps } from '@src/types/common'; import { StyledBody, StyledFooter, StyledHeader, StyledRow, StyledTable, } from './styled'; import Pagination from '../Pagination'; import { TbArrowNarrowRight } from 'react-icons/tb'; const parseWidthString = (columnsWidth: number[]): string => { let result: string = ''; const totalWidth = columnsWidth.reduce((partialSum, a) => partialSum + a, 0); columnsWidth.forEach((width) => { result += Math.round((width / totalWidth) * 100).toString() + '% '; }); return result; }; type Props = { columns: ColumnProps[]; rows: T[]; count?: number | null; }; const Table = ({ rows, columns, count }: Props) => { const width = parseWidthString(columns.map((item) => item.width)); const headers = columns.map((column, index) => { return
{column.title}
; }); const renderRows = rows.map((row, rowIndex) => { return ( } > {columns.map((column, columnIndex) => { const value = row[column.key as keyof typeof row] as string; if (column.isDateValue) { return (
{value[0]}     {value[1]}
); } return
{value}
; })}
); }); return ( {headers} {renderRows} {Boolean(count) && ( )} ); }; export default Table;