From 86b657b1b39d9b70bc81c2af520d4b2499299f63 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Wed, 22 May 2024 10:29:09 +0100 Subject: [PATCH] feat(website): improve review page by removing null values (#2000) * improve review page by removing null values * Automated code formatting --------- Co-authored-by: Loculus bot --- .../src/components/ReviewPage/ReviewCard.tsx | 22 ++++++++++--------- website/src/utils/displayMetadataField.ts | 16 +++++++++++++- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/website/src/components/ReviewPage/ReviewCard.tsx b/website/src/components/ReviewPage/ReviewCard.tsx index 1d4c5215c6..149dab3d1b 100644 --- a/website/src/components/ReviewPage/ReviewCard.tsx +++ b/website/src/components/ReviewPage/ReviewCard.tsx @@ -197,16 +197,18 @@ const isAnnotationPresent = (metadataField: string) => (item: ProcessingAnnotati const MetadataList: FC = ({ data, isLoading }) => !isLoading && - Object.entries(data.processedData.metadata).map(([metadataName, value], index) => ( - - )); + Object.entries(data.processedData.metadata).map(([metadataName, value], index) => + value === null ? null : ( + + ), + ); type ErrorsProps = { errors: ProcessingAnnotation[]; diff --git a/website/src/utils/displayMetadataField.ts b/website/src/utils/displayMetadataField.ts index 74b84460d8..3a72fa16bc 100644 --- a/website/src/utils/displayMetadataField.ts +++ b/website/src/utils/displayMetadataField.ts @@ -1,3 +1,17 @@ import type { MetadataField } from '../types/backend.ts'; -export const displayMetadataField = (value: MetadataField) => (value === null ? 'null' : value.toString()); +export const displayMetadataField = (value: MetadataField) => { + if (value === null) { + return 'null'; + } + + if (typeof value === 'number' && Number.isInteger(value)) { + return value.toString(); + } + + if (typeof value === 'number') { + return value.toFixed(2); + } + + return value.toString(); +};