From 00a7aabb0bf7c4d62401f7db00caeff9c894c6d3 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 16 May 2024 16:59:29 +0530 Subject: [PATCH] remove empty attributes and captialize values --- .../ConsultationDetails/Events/GenericEvent.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx index ec7e844b56e..3176e18f2f3 100644 --- a/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx +++ b/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx @@ -50,16 +50,20 @@ const formatValue = (value: unknown, key?: string): ReactNode => { return value.toLocaleString(); } - if (Object.entries(value).length === 0) { + const entries = Object.entries(value).filter( + ([_, value]) => value != null && value !== "", + ); + + if (entries.length === 0) { return `No ${key?.replaceAll(/_/g, " ")}`; } - return Object.entries(value).map(([key, value]) => ( + return entries.map(([key, value]) => (
{key.replaceAll(/_/g, " ")} - + {formatValue(value, key)}