2021-04-12 13:32:25 +00:00
|
|
|
import React from "react";
|
2021-02-11 16:22:22 +00:00
|
|
|
|
2021-03-03 16:51:39 +00:00
|
|
|
interface ITextCellProps {
|
2021-07-26 17:07:27 +00:00
|
|
|
value: string | number | boolean;
|
2021-03-03 16:51:39 +00:00
|
|
|
formatter?: (val: any) => string;
|
2021-08-16 16:25:51 +00:00
|
|
|
greyed?: string;
|
2021-03-03 16:51:39 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-22 15:34:45 +00:00
|
|
|
const TextCell = ({
|
|
|
|
|
value,
|
|
|
|
|
formatter = (val) => val, // identity function if no formatter is provided
|
|
|
|
|
greyed,
|
|
|
|
|
}: ITextCellProps): JSX.Element => {
|
2021-07-26 17:07:27 +00:00
|
|
|
let val = value;
|
|
|
|
|
|
|
|
|
|
if (typeof value === "boolean") {
|
|
|
|
|
val = value.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 16:25:51 +00:00
|
|
|
return <span className={greyed}>{formatter(val)}</span>;
|
2021-02-11 16:22:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TextCell;
|