Skip to content

Commit

Permalink
feat(website): improve review page by removing null values (#2000)
Browse files Browse the repository at this point in the history
* improve review page by removing null values

* Automated code formatting

---------

Co-authored-by: Loculus bot <[email protected]>
  • Loading branch information
theosanderson and Loculus bot authored May 22, 2024
1 parent dabff53 commit 86b657b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
22 changes: 12 additions & 10 deletions website/src/components/ReviewPage/ReviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,18 @@ const isAnnotationPresent = (metadataField: string) => (item: ProcessingAnnotati

const MetadataList: FC<MetadataListProps> = ({ data, isLoading }) =>
!isLoading &&
Object.entries(data.processedData.metadata).map(([metadataName, value], index) => (
<KeyValueComponent
accessionVersion={getAccessionVersionString(data)}
key={index}
keyName={metadataName}
value={displayMetadataField(value)}
warnings={data.warnings?.filter(isAnnotationPresent(metadataName))}
errors={data.errors?.filter(isAnnotationPresent(metadataName))}
/>
));
Object.entries(data.processedData.metadata).map(([metadataName, value], index) =>
value === null ? null : (
<KeyValueComponent
accessionVersion={getAccessionVersionString(data)}
key={index}
keyName={metadataName}
value={displayMetadataField(value)}
warnings={data.warnings?.filter(isAnnotationPresent(metadataName))}
errors={data.errors?.filter(isAnnotationPresent(metadataName))}
/>
),
);

type ErrorsProps = {
errors: ProcessingAnnotation[];
Expand Down
16 changes: 15 additions & 1 deletion website/src/utils/displayMetadataField.ts
Original file line number Diff line number Diff line change
@@ -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();
};

0 comments on commit 86b657b

Please sign in to comment.