add quotes around strings

This commit is contained in:
reesporte 2021-10-28 13:45:07 -05:00
parent b66a0316e6
commit aadfc63bf0

View file

@ -70,6 +70,32 @@ export const DataTable: FC<TableProps> = ({
}
};
const formatTableCell = (row: any, col: any) => {
if (typeof row[col.name] === 'object') {
return (
<pre className={css.preFormat}>
{JSON.stringify(row[col.name], null, 2)}
</pre> )
} else if (row[col.name] !== undefined) {
if (col.datatype === '[]string') {
return (
<span>
{'"' + (row[col.name]) + '"'}
</span>
)
}
return (
<span>
{col.datatype === 'timestamp' && row[col.name]
? moment
.utc(row[col.name])
.format('MM/DD/YYYY hh:mm:ss a')
: row[col.name].toLocaleString()}
</span> )
}
return null
}
return (
<Fragment>
<div ref={resultsRef} />
@ -117,20 +143,8 @@ export const DataTable: FC<TableProps> = ({
key={`table-cell-${rowIdx}-${colIdx}`}
className={css.tableCell}
>
{typeof row[col.name] === 'object' ? (
<pre className={css.preFormat}>
{JSON.stringify(row[col.name], null, 2)}
</pre>
) : row[col.name] !== undefined ? (
<span>
{col.datatype === 'timestamp' && row[col.name]
? moment
.utc(row[col.name])
.format('MM/DD/YYYY hh:mm:ss a')
: row[col.name].toLocaleString()}
</span>
) : null}
</TableCell>
{formatTableCell(row, col)}
</TableCell>
))}
{autoWidth ? <TableCell className={css.fillWidth} /> : null}
</TableRow>