Skip to content

Commit

Permalink
Merge pull request #19 from WorldHealthOrganization/feature/not_used_…
Browse files Browse the repository at this point in the history
…columns

Add new functionality to show unused columns.
  • Loading branch information
iorlas authored Jan 17, 2025
2 parents e31e92b + d7c111e commit 0e18e8b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ export const PackagePage = () => {

const breadcrumbsConfig = getBreadcrumbsConfig(packageId, packageData.name);

const attachments = match<ResistanceSampleType, typeof packageData['attachments'][number] | undefined>(activeTab)
.with('PDST', () => packageData?.attachments.find((item) => item.type === 'PDS'))
.with('MIC', () => packageData?.attachments.find((item) => item.type === 'MIC'))
.exhaustive();
const notUsedColumns = attachments?.metadata && 'notUsedColumns' in attachments.metadata
? attachments.metadata.notUsedColumns
: [];
const samplesByActiveTab = activeTab === 'PDST' ? packageData.pdsSamples : packageData.micSamples;
const controlsDisabled = packageData.state === 'ACCEPTED' || packageData.state === 'PENDING';
const syncAllowed = packageData.matchingState !== 'MATCHED';
Expand Down Expand Up @@ -246,6 +253,7 @@ export const PackagePage = () => {
activeTab={activeTab}
handleTabChange={handleTabChange}
tabs={tabs}
notUsedColumns={notUsedColumns}
/>
<SequencingData
isSomethingInSequencingDataLoading={isSomethingInSequencingDataLoading}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @jsxImportSource @emotion/react */
import React from 'react';
import {
Tab, Tabs,
Tab, Tabs, Alert,
} from '@mui/material';
import * as styles from './styles';
import type { ITab } from '../../PackagePage';
Expand Down Expand Up @@ -30,14 +30,15 @@ interface Props {
controlsDisabled: boolean;
packageId: number;
resistanceFileLabel: string;
fileError: IHttpError
fileError: IHttpError;
notUsedColumns: string[]
}

export const ResistanceData = ({
tabs, activeTab, handleTabChange, samplesData, isLoading,
onRemoveFileClick, isTabFileUploadError, errorFileName,
onRemoveErrorClick, controlsDisabled, packageId,
resistanceFileLabel, fileError,
resistanceFileLabel, fileError, notUsedColumns,
}: Props) => {
const renderSamplesContent = () => {
if (isLoading) {
Expand Down Expand Up @@ -73,6 +74,13 @@ export const ResistanceData = ({
fileName={resistanceFileLabel}
/>
)}
{notUsedColumns.length > 0 && (
<Alert variant="filled" severity="warning">
The following columns are not used:
&nbsp;
{notUsedColumns.join(', ')}
</Alert>
)}
{shouldRenderUnprocessedTable && (
<ResistanceDataTable
activeTab={activeTab}
Expand Down
3 changes: 3 additions & 0 deletions src/services/submissionApi/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ interface IPackageAttachment {
pk: number;
size: number;
type: PackageAttachmentType;
metadata: {
notUsedColumns: string[]
};
}

export interface IPackage {
Expand Down

0 comments on commit 0e18e8b

Please sign in to comment.