diff --git a/src/components/IndividualSearcher.js b/src/components/IndividualSearcher.js index d3ec6b7..76f15df 100644 --- a/src/components/IndividualSearcher.js +++ b/src/components/IndividualSearcher.js @@ -13,6 +13,7 @@ import { historyPush, downloadExport, CLEARED_STATE_FILTER, + decodeId, } from '@openimis/fe-core'; import { bindActionCreators } from 'redux'; import { connect, useDispatch } from 'react-redux'; @@ -69,6 +70,9 @@ function IndividualSearcher({ fieldsFromBfSchema, fetchingFieldsFromBfSchema, fetchedFieldsFromBfSchema, + isModalEnrollment, + advancedCriteria, + benefitPlanToEnroll, }) { const dispatch = useDispatch(); const [individualToDelete, setIndividualToDelete] = useState(null); @@ -172,7 +176,7 @@ function IndividualSearcher({ (individual) => individual.lastName, (individual) => (individual.dob ? formatDateFromISO(modulesManager, intl, individual.dob) : EMPTY_STRING), ]; - if (rights.includes(RIGHT_INDIVIDUAL_UPDATE)) { + if (rights.includes(RIGHT_INDIVIDUAL_UPDATE) && isModalEnrollment === false) { formatters.push((individual) => ( )); } - if (rights.includes(RIGHT_INDIVIDUAL_DELETE)) { + if (rights.includes(RIGHT_INDIVIDUAL_DELETE) && isModalEnrollment === false) { formatters.push((individual) => ( {failedExport && ( diff --git a/src/components/dialogs/AdvancedCriteriaForm.js b/src/components/dialogs/AdvancedCriteriaForm.js index 5b5db48..984e0dd 100644 --- a/src/components/dialogs/AdvancedCriteriaForm.js +++ b/src/components/dialogs/AdvancedCriteriaForm.js @@ -20,6 +20,7 @@ import AdvancedCriteriaRowValue from './AdvancedCriteriaRowValue'; import { CLEARED_STATE_FILTER, INDIVIDUAL } from '../../constants'; import { isBase64Encoded, isEmptyObject } from '../../utils'; import { confirmEnrollment, fetchIndividualEnrollmentSummary } from '../../actions'; +import IndividualPreviewEnrollmentDialog from './IndividualPreviewEnrollmentDialog'; const styles = (theme) => ({ item: theme.paper.item, @@ -48,6 +49,7 @@ function AdvancedCriteriaForm({ confirmed, clearConfirm, coreConfirm, + rights, edited, }) { // eslint-disable-next-line no-unused-vars @@ -55,6 +57,7 @@ function AdvancedCriteriaForm({ field: '', filter: '', type: '', value: '', amount: '', }); const [filters, setFilters] = useState(getDefaultAppliedCustomFilters()); + const [filtersToApply, setFiltersToApply] = useState(null); const getBenefitPlanDefaultCriteria = () => { const { jsonExt } = edited?.benefitPlan ?? {}; @@ -136,6 +139,7 @@ function AdvancedCriteriaForm({ // Extract custom_filter_condition values and construct customFilters array const customFilters = advancedCriteria.map((criterion) => `"${criterion.custom_filter_condition}"`); + setFiltersToApply(customFilters); const params = [ `customFilters: [${customFilters}]`, `benefitPlanId: "${decodeId(object.id)}"`, @@ -189,6 +193,7 @@ function AdvancedCriteriaForm({ // Extract custom_filter_condition values and construct customFilters array const customFilters = advancedCriteria.map((criterion) => `"${criterion.custom_filter_condition}"`); + setFiltersToApply(customFilters); const params = { customFilters: `[${customFilters}]`, benefitPlanId: `"${decodeId(object.id)}"`, @@ -344,7 +349,7 @@ function AdvancedCriteriaForm({ - + + diff --git a/src/components/dialogs/IndividualPreviewEnrollmentDialog.js b/src/components/dialogs/IndividualPreviewEnrollmentDialog.js new file mode 100644 index 0000000..f446a67 --- /dev/null +++ b/src/components/dialogs/IndividualPreviewEnrollmentDialog.js @@ -0,0 +1,123 @@ +/* eslint-disable max-len */ +import React, { useState } from 'react'; +import Button from '@material-ui/core/Button'; +import Dialog from '@material-ui/core/Dialog'; +import DialogActions from '@material-ui/core/DialogActions'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogTitle from '@material-ui/core/DialogTitle'; +import { + useModulesManager, + useTranslations, +} from '@openimis/fe-core'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; +import { INDIVIDUAL_MODULE_NAME } from '../../constants'; +import IndividualSearcher from '../IndividualSearcher'; + +function IndividualPreviewEnrollmentDialog({ + classes, + rights, + advancedCriteria, + benefitPlanToEnroll, + enrollmentSummary, + confirmed, +}) { + const [isOpen, setIsOpen] = useState(false); + + const handleOpen = () => { + setIsOpen(true); + }; + + const handleClose = () => { + setIsOpen(false); + }; + + const modulesManager = useModulesManager(); + const { formatMessage } = useTranslations(INDIVIDUAL_MODULE_NAME, modulesManager); + + return ( + <> + + + + {formatMessage('individual.enrollment.previewIndividuals')} + + +
+ +
+
+ +
+
+
+ +
+
+ +
+ + ); +} + +const mapStateToProps = (state) => ({ + rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [], + confirmed: state.core.confirmed, +}); + +const mapDispatchToProps = (dispatch) => bindActionCreators({ +}, dispatch); + +export default connect(mapStateToProps, mapDispatchToProps)(IndividualPreviewEnrollmentDialog); diff --git a/src/pages/IndividualsPage.js b/src/pages/IndividualsPage.js index 44d93c1..aa6fd8f 100644 --- a/src/pages/IndividualsPage.js +++ b/src/pages/IndividualsPage.js @@ -18,7 +18,7 @@ function IndividualsPage(props) { rights.includes(RIGHT_INDIVIDUAL_SEARCH) && (
- +
) ); diff --git a/src/translations/en.json b/src/translations/en.json index 6cc59c3..96d2106 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -70,7 +70,9 @@ "numberOfIndividualsNotAssignedToProgramme": "Number of Individuals Without Assignment to Program", "numberOfIndividualsAssignedToSelectedProgramme": "Number Of Individuals Already Assigned to Selected Programme", "numberOfIndividualsToBeUploaded": "Number Of Individuals to be Uploaded", - "confirmMessageDialog": "Are you sure you want to confirm the enrollment of the selected individuals into the {benefitPlanName} Programme?" + "confirmMessageDialog": "Are you sure you want to confirm the enrollment of the selected individuals into the {benefitPlanName} Programme?", + "previewIndividuals": "Preview Individuals", + "close": "Close" }, "saveButton.tooltip.enabled": "Save changes", "saveButton.tooltip.disabled": "Please fill General Information fields first",