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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TextCell = (props: ITextCellProps): JSX.Element => {
|
2021-02-11 16:22:22 +00:00
|
|
|
const {
|
|
|
|
|
value,
|
2021-04-12 13:32:25 +00:00
|
|
|
formatter = (val) => val, // identity function if no formatter is provided
|
2021-02-11 16:22:22 +00:00
|
|
|
} = props;
|
|
|
|
|
|
2021-07-26 17:07:27 +00:00
|
|
|
let val = value;
|
|
|
|
|
|
|
|
|
|
if (typeof value === "boolean") {
|
|
|
|
|
val = value.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <span>{formatter(val)}</span>;
|
2021-02-11 16:22:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TextCell;
|