From d4df35742cb9a456c2abaa866690cad633e3a480 Mon Sep 17 00:00:00 2001 From: sniedzielski Date: Thu, 29 Feb 2024 17:02:04 +0100 Subject: [PATCH 1/2] CM-715: added benefits tab --- src/components/BenefitsTab.js | 44 +++++++++++++++++++++++++++++++++++ src/constants.js | 3 +++ src/index.js | 3 +++ src/translations/en.json | 3 +++ 4 files changed, 53 insertions(+) create mode 100644 src/components/BenefitsTab.js diff --git a/src/components/BenefitsTab.js b/src/components/BenefitsTab.js new file mode 100644 index 0000000..ac51352 --- /dev/null +++ b/src/components/BenefitsTab.js @@ -0,0 +1,44 @@ +import React from 'react'; +import { Tab } from '@material-ui/core'; +import { + formatMessage, PublishedComponent, +} from '@openimis/fe-core'; +import { BENEFITS_TAB_VALUE, BENEFITS_CONTRIBUTION_KEY } from '../constants'; + +function BenefitsTabLabel({ + intl, onChange, tabStyle, isSelected, individual, +}) { + if (!individual) return null; + return ( + + ); +} + +function BenefitsTabPanel({ + value, individual, rights, classes, +}) { + if (!individual) return null; + return ( + + + + ); +} + +export { BenefitsTabLabel, BenefitsTabPanel }; diff --git a/src/constants.js b/src/constants.js index fe598a1..13ff83b 100644 --- a/src/constants.js +++ b/src/constants.js @@ -28,12 +28,14 @@ export const INDIVIDUAL_CHANGELOG_TAB_VALUE = 'IndividualChangelogTab'; export const INDIVIDUAL_TASK_TAB_VALUE = 'IndividualTaskTab'; export const GROUP_CHANGELOG_TAB_VALUE = 'GroupChangelogTab'; export const GROUP_TASK_TAB_VALUE = 'GroupTaskTab'; +export const BENEFITS_TAB_VALUE = 'BenefitTaskTab'; export const INDIVIDUAL_TABS_LABEL_CONTRIBUTION_KEY = 'individual.TabPanel.label'; export const INDIVIDUAL_TABS_PANEL_CONTRIBUTION_KEY = 'individual.TabPanel.panel'; export const BENEFIT_PLAN_TABS_LABEL_CONTRIBUTION_KEY = 'individual.BenefitPlansListTabLabel'; export const BENEFIT_PLAN_TABS_PANEL_CONTRIBUTION_KEY = 'individual.BenefitPlansListTabPanel'; export const TASK_CONTRIBUTION_KEY = 'tasksManagement.tasks'; +export const BENEFITS_CONTRIBUTION_KEY = 'payroll.benefitConsumptionPayrollSearcher'; export const BENEFICIARY_STATUS = { POTENTIAL: 'POTENTIAL', @@ -54,6 +56,7 @@ export const GROUP_INDIVIDUAL_ROLES_LIST = [ export const BENEFIT_PLAN_LABEL = 'BenefitPlan'; export const INDIVIDUAL_LABEL = 'Individual'; export const GROUP_LABEL = 'Group'; +export const BENEFITS_LABEL = 'Benefits'; export const INDIVIDUAL_MODULE_NAME = 'individual'; diff --git a/src/index.js b/src/index.js index 27c95c9..9112400 100644 --- a/src/index.js +++ b/src/index.js @@ -39,6 +39,7 @@ import { import { GROUP_LABEL, INDIVIDUAL_LABEL } from './constants'; import { GroupCreateTaskItemFormatters, GroupCreateTaskTableHeaders } from './components/tasks/GroupCreateTasks'; import IndividualsUploadDialog from './components/dialogs/IndividualsUploadDialog'; +import { BenefitsTabLabel, BenefitsTabPanel } from './components/BenefitsTab'; const ROUTE_INDIVIDUALS = 'individuals'; const ROUTE_INDIVIDUAL = 'individuals/individual'; @@ -83,6 +84,7 @@ const DEFAULT_CONFIG = { GroupChangelogTabLabel, GroupTaskTabLabel, IndividalTaskTabLabel, + BenefitsTabLabel, ], 'individual.TabPanel.panel': [ IndividualsListTabPanel, @@ -91,6 +93,7 @@ const DEFAULT_CONFIG = { IndividalChangelogTabPanel, GroupTaskTabPanel, IndividalTaskTabPanel, + BenefitsTabPanel, ], 'individual.BenefitPlansListTabLabel': [BENEFIT_PLAN_TABS_LABEL_REF_KEY], 'individual.BenefitPlansListTabPanel': [BENEFIT_PLAN_TABS_PANEL_REF_KEY], diff --git a/src/translations/en.json b/src/translations/en.json index a79d15b..6cc59c3 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -20,6 +20,9 @@ "lastName": "Last Name", "dob": "Day of birth", "mandatoryFieldsEmptyError": "* These fields are required", + "benefits": { + "label": "Benefits" + }, "delete": { "confirm": { "title": "Delete {firstName} {lastName}?", From 8c0ba304a502f94ad9f9c2da5311bcafcb46cb98 Mon Sep 17 00:00:00 2001 From: sniedzielski Date: Mon, 4 Mar 2024 13:48:26 +0100 Subject: [PATCH 2/2] CM-738: added possibility to preview individual --- src/components/IndividualSearcher.js | 23 +++- .../dialogs/AdvancedCriteriaForm.js | 13 +- .../IndividualPreviewEnrollmentDialog.js | 120 ++++++++++++++++++ src/pages/IndividualsPage.js | 2 +- src/translations/en.json | 4 +- 5 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 src/components/dialogs/IndividualPreviewEnrollmentDialog.js 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 55a0722..9daba60 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,12 +49,14 @@ function AdvancedCriteriaForm({ confirmed, clearConfirm, coreConfirm, + rights, }) { // eslint-disable-next-line no-unused-vars const [currentFilter, setCurrentFilter] = useState({ field: '', filter: '', type: '', value: '', amount: '', }); const [filters, setFilters] = useState(getDefaultAppliedCustomFilters()); + const [filtersToApply, setFiltersToApply] = useState(null); const createParams = (moduleName, objectTypeName, uuidOfObject = null, additionalParams = null) => { const params = [ @@ -119,6 +122,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)}"`, @@ -172,6 +176,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)}"`, @@ -327,7 +332,7 @@ function AdvancedCriteriaForm({ - + + diff --git a/src/components/dialogs/IndividualPreviewEnrollmentDialog.js b/src/components/dialogs/IndividualPreviewEnrollmentDialog.js new file mode 100644 index 0000000..7b1d483 --- /dev/null +++ b/src/components/dialogs/IndividualPreviewEnrollmentDialog.js @@ -0,0 +1,120 @@ +/* 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, +}) { + 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",