fleet/frontend/components/TableContainer/DataTable/TextCell/TextCell.tsx
2022-03-10 10:10:44 -05:00

23 lines
506 B
TypeScript

import React from "react";
interface ITextCellProps {
value: string | number | boolean;
formatter?: (val: any) => string; // string, number, or null
greyed?: string;
}
const TextCell = ({
value,
formatter = (val) => val, // identity function if no formatter is provided
greyed,
}: ITextCellProps): JSX.Element => {
let val = value;
if (typeof value === "boolean") {
val = value.toString();
}
return <span className={greyed}>{formatter(val)}</span>;
};
export default TextCell;