diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index 2c4349177a5..1fd0724ed8c 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -9,8 +9,8 @@ interface IProps { * object - array, date */ const formatValue = (value: unknown, key?: string): ReactNode => { - if (value == null) { - return "N/A"; + if (value == null || value === "N/A") { + return null; } if (typeof value === "boolean") { @@ -25,7 +25,7 @@ const formatValue = (value: unknown, key?: string): ReactNode => { const trimmed = value.trim().replaceAll(/_/g, " "); if (trimmed === "") { - return "Empty"; + return null; } if (!isNaN(Number(trimmed))) { @@ -50,8 +50,8 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return ( ); @@ -69,8 +69,8 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return `No ${key?.replaceAll(/_/g, " ")}`; } - return entries.map(([key, value]) => ( -
+ return entries.map(([key, value], idx) => ( +
{key.replaceAll(/_/g, " ")} @@ -88,16 +88,19 @@ export default function GenericEvent(props: IProps) { const { t } = useTranslation(); return (
- {Object.entries(props.values).map(([key, value]) => ( -
- - {t(key).replaceAll(/_/g, " ")} - - - {formatValue(value, key)} - -
- ))} + {Object.entries(props.values) + .map(([key, value]) => ({ key, value: formatValue(value, key) })) + .filter(({ value }) => value != null) + .map(({ key, value }) => ( +
+ + {t(key).replaceAll(/_/g, " ")} + + + {value} + +
+ ))}
); }