-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CM-947: added possibility to create review task for payment deduplica…
…tion
- Loading branch information
1 parent
1158ae3
commit f26661a
Showing
6 changed files
with
254 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* eslint-disable react/no-array-index-key */ | ||
import React, { useState, useEffect } from 'react'; | ||
import { | ||
makeStyles, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Checkbox, | ||
} from '@material-ui/core'; | ||
import { | ||
FormattedMessage, | ||
} from '@openimis/fe-core'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
paper: theme.paper.paper, | ||
table: theme.table, | ||
tableTitle: theme.table.title, | ||
tableHeader: theme.table.header, | ||
tableRow: theme.table.row, | ||
title: theme.paper.title, | ||
tableDisabledRow: theme.table.disabledRow, | ||
tableDisabledCell: theme.table.disabledCell, | ||
tableContainer: { | ||
overflow: 'auto', | ||
}, | ||
hoverableCell: { | ||
'&:hover': { | ||
backgroundColor: '#f0f0f0', | ||
}, | ||
cursor: 'pointer', | ||
}, | ||
selectedCell: { | ||
backgroundColor: '#a1caf1', | ||
}, | ||
checkboxCell: { | ||
textAlign: 'center', | ||
}, | ||
deactivatedRow: { | ||
opacity: 0.5, | ||
}, | ||
strikethrough: { | ||
textDecoration: 'line-through', | ||
}, | ||
})); | ||
|
||
function BenefitPaymentDuplicatesTable({ | ||
headers, rows, completedData, | ||
}) { | ||
const classes = useStyles(); | ||
const [dontMergeRows, setDontMergeRows] = useState([]); | ||
const shouldDisableCell = (rowIndex) => dontMergeRows.includes(rowIndex); | ||
const shouldCrossText = (rowIndex) => rows[rowIndex]?.is_deleted; | ||
|
||
useEffect(() => { | ||
if (completedData) { | ||
const numberOfRows = Array.from(Array(rows.length).keys()); | ||
setDontMergeRows(numberOfRows); | ||
} | ||
}, [completedData]); | ||
|
||
return ( | ||
<div className={classes.tableContainer}> | ||
<TableContainer className={classes.paper}> | ||
<Table size="small" className={classes.table} aria-label="dynamic table"> | ||
<TableHead className={classes.header}> | ||
<TableRow className={classes.header}> | ||
<TableCell key="checkbox-header-merge" className={classes.checkboxCell}> | ||
<FormattedMessage module="deduplication" id="BeneficiaryDuplicatesTable.merge.header" /> | ||
</TableCell> | ||
<TableCell key="checkbox-header" className={classes.checkboxCell}> | ||
<FormattedMessage module="deduplication" id="BeneficiaryDuplicatesTable.checkbox.header" /> | ||
</TableCell> | ||
{headers.map((header, index) => ( | ||
<TableCell key={index}>{header}</TableCell> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows.map((row, rowIndex) => ( | ||
<TableRow | ||
key={rowIndex} | ||
className={classes.tableRow} | ||
> | ||
<TableCell key={`checkbox-cell-${rowIndex}`} className={classes.checkboxCell}> | ||
<Checkbox | ||
color="primary" | ||
onChange={() => {}} | ||
disabled={shouldDisableCell(rowIndex)} | ||
/> | ||
</TableCell> | ||
{headers.map((header, headerIndex) => ( | ||
<TableCell | ||
key={headerIndex} | ||
className={`} | ||
${shouldDisableCell(rowIndex) ? classes.tableDisabledCell : ''} | ||
${shouldCrossText(rowIndex) ? classes.strikethrough : ''} | ||
`} | ||
> | ||
{row[header]} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
<TableRow | ||
className={classes.tableRow} | ||
> | ||
<TableCell className={classes.checkboxCell} /> | ||
<TableCell className={classes.checkboxCell}> | ||
<FormattedMessage module="deduplication" id="BeneficiaryDuplicatesTable.output" /> | ||
</TableCell> | ||
{headers.map((header, headerIndex) => ( | ||
<TableCell | ||
key={headerIndex} | ||
className={`${classes.tableDisabledCell} | ||
${completedData ? classes.selectedCell : ''}`} | ||
> | ||
{rows[0][header]} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</div> | ||
); | ||
} | ||
|
||
export default BenefitPaymentDuplicatesTable; |
79 changes: 79 additions & 0 deletions
79
src/components/tasks/DeduplicationPaymentResolutionTask.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import { Typography, makeStyles } from '@material-ui/core'; | ||
import BenefitPaymentDuplicatesTable from '../tables/BenefitPaymentDuplicatesTable'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
paper: theme.paper.paper, | ||
title: theme.paper.title, | ||
})); | ||
|
||
function DeduplicationPaymentResolutionTaskDisplay({ | ||
businessData, setAdditionalData, jsonExt, | ||
}) { | ||
if (!businessData) return null; | ||
|
||
const classes = useStyles(); | ||
const completedData = jsonExt?.additional_resolve_data | ||
? Object.values(jsonExt.additional_resolve_data)[0].values | ||
: null; | ||
const benefits = (businessData?.ids || []).map((id) => { | ||
const { | ||
// eslint-disable-next-line camelcase | ||
individual, json_ext, uuid, ...rest | ||
} = id; | ||
return { | ||
...rest, | ||
...individual, | ||
// eslint-disable-next-line camelcase | ||
...json_ext, | ||
individual: individual.uuid, | ||
benefitId: uuid, | ||
}; | ||
}); | ||
|
||
const headers = businessData?.headers || []; | ||
const individualIndex = headers.indexOf('individual'); | ||
|
||
if (individualIndex !== -1) { | ||
headers.splice(individualIndex, 1); | ||
headers.unshift('individual'); | ||
} | ||
|
||
benefits.sort((a, b) => new Date(a.date_created) - new Date(b.date_created)); | ||
|
||
return ( | ||
<div> | ||
<Typography className={classes.title} style={{ textAlign: 'center' }}> | ||
{JSON.stringify(businessData?.column_values)} | ||
{' '} | ||
, | ||
count: | ||
{' '} | ||
{businessData?.count} | ||
</Typography> | ||
<div> | ||
<BenefitPaymentDuplicatesTable | ||
headers={headers} | ||
rows={benefits} | ||
setAdditionalData={setAdditionalData} | ||
completedData={completedData} | ||
/> | ||
|
||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
const DeduplicationPaymentResolutionTaskTableHeaders = () => []; | ||
|
||
const DeduplicationPaymentResolutionItemFormatters = () => [ | ||
(businessData, jsonExt, formatterIndex, setAdditionalData) => ( | ||
<DeduplicationPaymentResolutionTaskDisplay | ||
businessData={businessData} | ||
setAdditionalData={setAdditionalData} | ||
jsonExt={jsonExt} | ||
/> | ||
), | ||
]; | ||
|
||
export { DeduplicationPaymentResolutionTaskTableHeaders, DeduplicationPaymentResolutionItemFormatters }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters