Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(website): improve review page by removing null values #2000

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
};