From 959946cbfceb406d10b9f0f7b674321ce50a9223 Mon Sep 17 00:00:00 2001 From: chisom chima Date: Thu, 28 Mar 2024 16:45:14 +0100 Subject: [PATCH] p feat : update the summary table to display a message --- src/components/JobSummary/Summary/Summary.js | 29 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/components/JobSummary/Summary/Summary.js b/src/components/JobSummary/Summary/Summary.js index 5fd1f48c..92dd8a57 100644 --- a/src/components/JobSummary/Summary/Summary.js +++ b/src/components/JobSummary/Summary/Summary.js @@ -1,3 +1,5 @@ +import i18n from '@dhis2/d2-i18n' +import { NoticeBox } from '@dhis2/ui' import PropTypes from 'prop-types' import React from 'react' import { typeReportParse } from '../helper.js' @@ -6,7 +8,7 @@ import { TypeReportSummary } from '../TypeReportSummary/TypeReportSummary.js' import styles from './Summary.module.css' const extractStats = (summary) => { - if (summary.responseType == 'ImportSummaries') { + if (summary.responseType === 'ImportSummaries') { const { imported, deleted, ignored, updated, total } = summary return { imported, deleted, ignored, updated, total } } else if (summary.importCount) { @@ -18,7 +20,26 @@ const extractStats = (summary) => { } } -const Summary = ({ summary, importType }) => { +const Summary = ({ summary, importType, dryRun }) => { + // Check for dry run + if (dryRun) { + const { ignored, total } = extractStats(summary) + return ( +
+
+ + {i18n.t( + `${ignored} entities will be ignored out of ${total} entitiesā ` + )} + +
+
+ ) + } + // gml import type object return if (summary.typeReports) { const overviewStats = { @@ -56,8 +77,9 @@ const Summary = ({ summary, importType }) => { } /> ) + const allSummaries = - summary.responseType == 'ImportSummaries' && summary.importSummaries + summary.responseType === 'ImportSummaries' && summary.importSummaries ? summary.importSummaries.map((s, i) => { const importCount = extractStats(s) return ( @@ -86,6 +108,7 @@ const Summary = ({ summary, importType }) => { Summary.propTypes = { summary: PropTypes.object.isRequired, + dryRun: PropTypes.bool, importType: PropTypes.string, }