Skip to content

Commit

Permalink
feat: update the summary table to display a message
Browse files Browse the repository at this point in the history
  • Loading branch information
Chisomchima committed Apr 21, 2024
1 parent 6cd4f22 commit 402dacc
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/components/JobSummary/Summary/Summary.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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) {
Expand All @@ -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 (
<div data-test="job-summary-summary" className={styles.container}>
<div
className={styles.rest}
data-test="job-summary-summary-rest"
>
<NoticeBox title="Summary">
{i18n.t(
`${ignored} entities will be ignored out of ${total} entities⁠`
)}
</NoticeBox>
</div>
</div>
)
}

// gml import type object return
if (summary.typeReports) {
const overviewStats = {
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -86,6 +108,7 @@ const Summary = ({ summary, importType }) => {

Summary.propTypes = {
summary: PropTypes.object.isRequired,
dryRun: PropTypes.bool,
importType: PropTypes.string,
}

Expand Down

0 comments on commit 402dacc

Please sign in to comment.