diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 910046cc..c4bbe010 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -21,7 +21,7 @@ "copy-tailwind": "cp src/tailwind.cjs dist/tailwind.cjs", "build": "npm run compile && npm run types && npm run copy-tailwind && npm run rollup", "build:clean": "npm run clean && npm run build", - "build:watch": "npm run build -- --watch", + "build:watch": "npm run compile && npm run rollup -- --watch", "dev": "npm run build:watch" }, "exports": { diff --git a/packages/frontend/src/features/Discovery/Discovery.tsx b/packages/frontend/src/features/Discovery/Discovery.tsx index ca03b8c8..2993d8af 100644 --- a/packages/frontend/src/features/Discovery/Discovery.tsx +++ b/packages/frontend/src/features/Discovery/Discovery.tsx @@ -76,7 +76,7 @@ const Discovery = ({ {discoveryConfig?.features?.pageTitle.text} ) : null } -
+
@@ -111,7 +111,7 @@ const Discovery = ({ opened={showAdvancedSearch} setAdvancedSearchFilters={setAdvancedSearchTerms} /> : false } -
+
value; }; -export const RenderArrayCellNegativePositive : CellRendererFunction = ({ +export const RenderArrayCellNegativePositive: CellRendererFunction = ({ value, cell, }: CellRenderFunctionProps) => { @@ -56,7 +56,9 @@ export const RenderArrayCellNegativePositive : CellRendererFunction = ({ return {value as any}; }; -export const RenderLinkCell : CellRendererFunction = ({ value }: CellRenderFunctionProps) => { +export const RenderLinkCell: CellRendererFunction = ({ + value, +}: CellRenderFunctionProps) => { const content = value as string; return ( { +const RenderStringCell: CellRendererFunction = ( + { value }: CellRenderFunctionProps, + params?: JSONObject, +) => { const content = value as string | string[]; if (content === undefined || content === null) { - return {`${params && params?.valueIfNotAvailable ? params?.valueIfNotAvailable : ''}`} ; + return ( + + {`${ + params && params?.valueIfNotAvailable + ? params?.valueIfNotAvailable + : '' + }`}{' '} + + ); } if (content == '') { - return {`${params && params?.valueIfNotAvailable ? params?.valueIfNotAvailable : ''}`} ; + return ( + + {`${ + params && params?.valueIfNotAvailable + ? params?.valueIfNotAvailable + : '' + }`}{' '} + + ); } return {isArray(content) ? content.join(', ') : content}; }; -const RenderNumberCell : CellRendererFunction = ({ value }: CellRenderFunctionProps, params? : JSONObject) => { +const RenderNumberCell: CellRendererFunction = ( + { value }: CellRenderFunctionProps, + params?: JSONObject, +) => { + const isContentEmpty = value === undefined || value === null; + const paramsValueIfNotAvailable = params && params?.valueIfNotAvailable; const content = value as number | number[]; - if (content === undefined || content === null) { - return {`${params && params?.valueIfNotAvailable ? params?.valueIfNotAvailable : ''}`} ; + + if (isContentEmpty) { + return ( + {`${ + paramsValueIfNotAvailable ? paramsValueIfNotAvailable : '' + }`} + ); } - return ( - - {isArray(content) - ? content.map((v) => v ? v.toLocaleString() : "").join('; ') - : content.toLocaleString()} - - ); + + let stringValue = ''; + // check if content is an array of all numbers + if (isArray(content) && content.every((item) => typeof item === 'number')) { + stringValue = content.map((v) => (v ? v.toLocaleString() : '')).join('; '); + } else { + stringValue = content.toLocaleString(); + } + + return {stringValue}; }; -const RenderParagraphsCell : CellRendererFunction = ({ value }: CellRenderFunctionProps) => { +const RenderParagraphsCell: CellRendererFunction = ({ + value, +}: CellRenderFunctionProps) => { const content = value as string | string[]; return ( @@ -117,7 +153,9 @@ interface TagData { // TODO Fix below // eslint-disable-next-line react/prop-types -export const RenderTagsCell : CellRendererFunction = ({ value }: CellRenderFunctionProps) => { +export const RenderTagsCell: CellRendererFunction = ({ + value, +}: CellRenderFunctionProps) => { const content = value as TagData[]; const { discoveryConfig: config } = useDiscoveryContext(); return ( @@ -128,7 +166,9 @@ export const RenderTagsCell : CellRendererFunction = ({ value }: CellRenderFunct