Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

fix: OPTIC-152: Uploading a text field but only 'true' is showing up not 'false' #294

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/CellViews/DateTimeCell.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { format, isValid } from "date-fns";
export const dateTimeFormat = "MMM dd yyyy, HH:mm:ss";

export const DateTimeCell = (column) => {
const date = new Date(column.value);
const dateFormat = "MMM dd yyyy, HH:mm:ss";

return column.value ? (
<div style={{ whiteSpace: "nowrap" }}>
{isValid(date) ? format(date, dateFormat) : ""}
{isValid(date) ? format(date, dateTimeFormat) : ""}
</div>
) : (
""
Expand Down
29 changes: 18 additions & 11 deletions src/components/CellViews/StringCell.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
const valueToString = (value) => {
import { format, isValid } from "date-fns";
import { dateTimeFormat } from "./DateTimeCell";

export const valueToString = (value) => {
if (typeof value === "string") return value;
/* if undefined or null we'll treat it as empty string */
if (value === undefined || value === null) return "";
if (value instanceof Date && isValid(value)) return format(value, dateTimeFormat);

try {
/* JSON.stringify will handle JSON and non-strings, non-null, non-undefined */
return JSON.stringify(value);
} catch {
return value.toString();
return 'Error: Invalid JSON';
}
};

export const StringCell = ({ value }) => {
const style = {
maxHeight: "100%",
overflow: "hidden",
fontSize: 12,
lineHeight: "16px",
};

return (
<div
style={{
maxHeight: "100%",
overflow: "hidden",
fontSize: 12,
lineHeight: "16px",
}}
>
{value ? valueToString(value) : ""}
<div style={style}>
{valueToString(value)}
</div>
);
};
Loading