interface CardTableRowInterface {
key: string;
label?: string;
value?: (data: any) => React.ReactElement;
children: React.ReactNode;
}
export interface CardTableProps extends CardTableStyleProps {
data: Record<string, unknown>;
rows: Array<CardTableRowInterface | string>;
size?: "large" | "medium";
disableBlankRows?: boolean;
CardHeaderProps?: CardHeaderProps;
}
const CardTable: React.FC<CardTableProps> = (props) => {
const { data, rows, size = "medium", disableBlankRows, ...rest } = props;
const isLarge = size === "large";
return (
<StyledTable {...rest}>
<TableBody>
{rows.map((row) => {
const key = typeof row === "object" ? row.key : row;
const label =
typeof row === "object"
? getLabelFromKey(row.label || key)
: getLabelFromKey(row);
const value =
typeof row === "object" && typeof row.value === "function"
? row.value(data)
: get(data, key);
if (!value && disableBlankRows) return;
return (
<TableRow key={key}>
<TableCell className={classes.tableColumnHeaderCell}>
<Typography variant={isLarge ? "h5" : "h6"}>{label}</Typography>
</TableCell>
<TableCell>
<Typography variant="body2" color="textSecondary">
{value}
</Typography>
</TableCell>
</TableRow>
);
})}
</TableBody>
</StyledTable>
);
};
Error:
Type error: No overload matches this call.
Overload 1 of 2, '(props: { component: ElementType<any>; } & SystemProps<Theme> & { align?: "left" | "center" | "right" | "inherit" | "justify"; children?: ReactNode; ... 6 more ...; variantMapping?: Partial<...>; } & CommonProps & Omit<...>): Element', gave the following error.
Type 'unknown' is not assignable to type 'ReactNode'.
Overload 2 of 2, '(props: DefaultComponentProps<TypographyTypeMap<{}, "span">>): Element', gave the following error.
Type 'unknown' is not assignable to type 'ReactNode'.
81 | <TableCell>
82 | <Typography variant="body2" color="textSecondary">
> 83 | {value}
| ^
84 | </Typography>
85 | </TableCell>
86 | </TableRow>