Skip to content

Commit d754d31

Browse files
frano-mFran McDade
andauthored
fix: fix data dictionary basiccell component to render boolean values as string (#474) (#475)
* fix: fix data dictionary basiccell component to render boolean values as string (#474) * fix: linting (#474) --------- Co-authored-by: Fran McDade <franmcdade@Frans-MacBook-Pro.local>
1 parent 992a0f2 commit d754d31

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ import { Typography } from "@mui/material";
22
import { CellContext, RowData } from "@tanstack/react-table";
33
import React, { ReactNode } from "react";
44
import { TYPOGRAPHY_PROPS } from "../../../../../../styles/common/mui/typography";
5+
import { parseValue } from "./utils";
56

6-
export const BasicCell = <T extends RowData, TValue>({
7+
export const BasicCell = <
8+
T extends RowData,
9+
TValue extends ReactNode = ReactNode
10+
>({
711
getValue,
812
}: CellContext<T, TValue>): JSX.Element | null => {
913
const value = getValue();
1014
if (value === undefined || value === null) return null;
1115
return (
1216
<Typography variant={TYPOGRAPHY_PROPS.VARIANT.INHERIT}>
13-
{value as ReactNode}
17+
{parseValue(value)}
1418
</Typography>
1519
);
1620
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ReactNode } from "react";
2+
3+
/**
4+
* Returns a parsed value based on the original value.
5+
* If the value is a boolean, it is converted to its string representation ("true" or "false").
6+
* For all other types of ReactNode, the value is returned unchanged.
7+
* @param value - The original value.
8+
* @returns Parsed value or original value.
9+
*/
10+
export function parseValue(value: ReactNode): ReactNode {
11+
if (typeof value === "boolean") return value.toString();
12+
return value;
13+
}

0 commit comments

Comments
 (0)