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;
|
2022-03-10 15:10:44 +00:00
|
|
|
formatter?: (val: any) => string; // string, number, or null
|
2021-08-16 16:25:51 +00:00
|
|
|
greyed?: string;
|
2022-04-07 19:12:38 +00:00
|
|
|
classes?: 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,
|
2022-04-07 19:12:38 +00:00
|
|
|
classes: className = "w250",
|
2021-10-22 15:34:45 +00:00
|
|
|
}: ITextCellProps): JSX.Element => {
|
2021-07-26 17:07:27 +00:00
|
|
|
let val = value;
|
|
|
|
|
|
|
|
|
|
if (typeof value === "boolean") {
|
|
|
|
|
val = value.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-07 19:12:38 +00:00
|
|
|
return (
|
|
|
|
|
<span className={`text-cell ${className} ${greyed || ""}`}>
|
|
|
|
|
{formatter(val)}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2021-02-11 16:22:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TextCell;
|