Skip to content

Commit

Permalink
CM-447: last adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Apr 4, 2024
1 parent 53433c2 commit cd339cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
42 changes: 28 additions & 14 deletions src/components/BeneficiaryDuplicatesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const useStyles = makeStyles((theme) => ({
deactivatedRow: {
opacity: 0.5,
},
strikethrough: {
textDecoration: 'line-through',
},
}));

function BeneficiaryDuplicatesTable({
Expand All @@ -49,14 +52,14 @@ function BeneficiaryDuplicatesTable({
const filteredIds = rows
.filter((row, index) => !dontMergeRows.includes(index))
.map((row) => row.beneficiaryId);
const parsedFieldValues = selectedCells.reduce((acc, cell) => {
acc[cell.header] = cell.value ?? '';
return acc;
const parsedFieldValues = selectedCells.reduce((accumulation, cell) => {
accumulation[cell.header] = cell.value ?? '';

Check failure on line 56 in src/components/BeneficiaryDuplicatesTable.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to property of function parameter 'accumulation'
return accumulation;
}, {});
setFieldValues(parsedFieldValues);
const additionalData = (
{ values: fieldValues, beneficiaryIds: filteredIds }
{ values: parsedFieldValues, beneficiaryIds: filteredIds }
);
setFieldValues(parsedFieldValues);
// eslint-disable-next-line max-len
const additionalDataString = `{\\"values\\": ${JSON.stringify(additionalData.values).replace(/"/g, '\\"')},\\"beneficiaryIds\\": ${JSON.stringify(additionalData.beneficiaryIds).replace(/"/g, '\\"')}}`;
setAdditionalData(additionalDataString);
Expand Down Expand Up @@ -141,6 +144,10 @@ function BeneficiaryDuplicatesTable({
// eslint-disable-next-line max-len
const shouldHoverCell = (rowIndex, header) => !isCellSelected(rowIndex, header) && header !== 'individual' && !dontMergeRows.includes(rowIndex);
const shouldDisableCell = (rowIndex) => dontMergeRows.includes(rowIndex);
const shouldCrossText = (rowIndex) => rows[rowIndex]?.is_deleted;
const isDontMereChecked = (rowIndex) => (
(dontMergeRows.includes(rowIndex) && !completedData) || (completedData && !rows[rowIndex]?.is_deleted)
);

useEffect(() => {
if (completedData) {
Expand Down Expand Up @@ -174,12 +181,16 @@ function BeneficiaryDuplicatesTable({
className={classes.tableRow}
>
<TableCell key={`merge-cell-${rowIndex}`} className={classes.checkboxCell}>
<Checkbox
color="primary"
checked={dontMergeRows.includes(rowIndex) && !completedData}
onChange={() => handleMergeCheckboxChange(rowIndex)}
disabled={completedData}
/>
{rowIndex
? (
<Checkbox
color="primary"
checked={isDontMereChecked(rowIndex)}
onChange={() => handleMergeCheckboxChange(rowIndex)}
disabled={completedData}
/>
)
: <FormattedMessage module="deduplication" id="BeneficiaryDuplicatesTable.oldest" />}
</TableCell>
<TableCell key={`checkbox-cell-${rowIndex}`} className={classes.checkboxCell}>
<Checkbox
Expand All @@ -192,9 +203,12 @@ function BeneficiaryDuplicatesTable({
{headers.map((header, headerIndex) => (
<TableCell
key={headerIndex}
className={`${isCellSelected(rowIndex, header) ? classes.selectedCell : ''} ${
shouldHoverCell(rowIndex, header) ? classes.hoverableCell : ''
} ${shouldDisableCell(rowIndex) ? classes.tableDisabledCell : ''}`}
className={`
${isCellSelected(rowIndex, header) ? classes.selectedCell : ''}
${shouldHoverCell(rowIndex, header) ? classes.hoverableCell : ''}
${shouldDisableCell(rowIndex) ? classes.tableDisabledCell : ''}
${shouldCrossText(rowIndex) ? classes.strikethrough : ''}
`}
onClick={() => handleCellClick(rowIndex, header, row[header])}
>
{row[header]}
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"deduplication.deduplicate.mutation.createTasks": "Deduplication tasks have been created.",
"deduplication.BeneficiaryDuplicatesTable.checkbox.header": "Select all columns",
"deduplication.BeneficiaryDuplicatesTable.merge.header": "Don't merge",
"deduplication.BeneficiaryDuplicatesTable.output": "OUTPUT:"
"deduplication.BeneficiaryDuplicatesTable.output": "OUTPUT:",
"deduplication.BeneficiaryDuplicatesTable.oldest": "Oldest"
}

0 comments on commit cd339cf

Please sign in to comment.