diff --git a/src/actions.js b/src/actions.js
index dc5974e..c37b2f5 100644
--- a/src/actions.js
+++ b/src/actions.js
@@ -237,6 +237,22 @@ export function deleteBenefitPlan(benefitPlan, clientMutationLabel) {
);
}
+export function closeBenefitPlan(benefitPlan, clientMutationLabel) {
+ const benefitPlanUuids = `ids: ["${benefitPlan?.id}"]`;
+ const mutation = formatMutation('closeBenefitPlan', benefitPlanUuids, clientMutationLabel);
+ const requestedDateTime = new Date();
+ return graphql(
+ mutation.payload,
+ [REQUEST(ACTION_TYPE.MUTATION), SUCCESS(ACTION_TYPE.CLOSE_BENEFIT_PLAN), ERROR(ACTION_TYPE.MUTATION)],
+ {
+ actionType: ACTION_TYPE.CLOSE_BENEFIT_PLAN,
+ clientMutationId: mutation.clientMutationId,
+ clientMutationLabel,
+ requestedDateTime,
+ },
+ );
+}
+
function dateTimeToDate(date) {
return date.split('T')[0];
}
diff --git a/src/pages/BenefitPlanPage.js b/src/pages/BenefitPlanPage.js
index 878df5a..1ab8fe9 100644
--- a/src/pages/BenefitPlanPage.js
+++ b/src/pages/BenefitPlanPage.js
@@ -15,9 +15,10 @@ import { connect } from 'react-redux';
import _ from 'lodash';
import { withTheme, withStyles } from '@material-ui/core/styles';
import DeleteIcon from '@material-ui/icons/Delete';
+import PauseIcon from '@material-ui/icons/Pause';
import { RIGHT_BENEFICIARY_SEARCH, RIGHT_BENEFIT_PLAN_UPDATE } from '../constants';
import {
- fetchBenefitPlan, deleteBenefitPlan, updateBenefitPlan, clearBenefitPlan, createBenefitPlan,
+ fetchBenefitPlan, deleteBenefitPlan, closeBenefitPlan, updateBenefitPlan, clearBenefitPlan, createBenefitPlan,
} from '../actions';
import BenefitPlanHeadPanel from '../components/BenefitPlanHeadPanel';
import BenefitPlanTabPanel from '../components/BenefitPlanTabPanel';
@@ -38,6 +39,7 @@ function BenefitPlanPage({
benefitPlan,
fetchBenefitPlan,
deleteBenefitPlan,
+ closeBenefitPlan,
updateBenefitPlan,
coreConfirm,
clearConfirm,
@@ -147,6 +149,13 @@ function BenefitPlanPage({
}),
);
+ const stopBenefitPlanCallback = () => closeBenefitPlan(
+ benefitPlan,
+ formatMessageWithValues(intl, 'socialProtection', 'benefitPlan.delete.mutationLabel', {
+ id: benefitPlan?.id,
+ }),
+ );
+
const openDeleteBenefitPlanConfirmDialog = () => {
setConfirmedAction(() => deleteBenefitPlanCallback);
coreConfirm(
@@ -158,6 +167,17 @@ function BenefitPlanPage({
);
};
+ const openStopBenefitPlanConfirmDialog = () => {
+ setConfirmedAction(() => stopBenefitPlanCallback);
+ coreConfirm(
+ formatMessageWithValues(intl, 'socialProtection', 'benefitPlan.suspend.confirm.title', {
+ code: benefitPlan?.code,
+ name: benefitPlan?.name,
+ }),
+ formatMessage(intl, 'socialProtection', 'benefitPlan.suspend.confirm.message'),
+ );
+ };
+
const getBenefitPlanPanels = () => {
const panels = [];
if (benefitPlan?.id && benefitPlan?.beneficiaryDataSchema) {
@@ -174,6 +194,10 @@ function BenefitPlanPage({
doIt: openDeleteBenefitPlanConfirmDialog,
icon: ,
tooltip: formatMessage(intl, 'socialProtection', 'deleteButtonTooltip'),
+ }, {
+ doIt: openStopBenefitPlanConfirmDialog,
+ icon: ,
+ tooltip: formatMessage(intl, 'socialProtection', 'stopButtonTooltip'),
},
];
@@ -231,6 +255,7 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
fetchBenefitPlan,
clearBenefitPlan,
deleteBenefitPlan,
+ closeBenefitPlan,
updateBenefitPlan,
coreConfirm,
clearConfirm,
diff --git a/src/reducer.js b/src/reducer.js
index f71b455..c602705 100644
--- a/src/reducer.js
+++ b/src/reducer.js
@@ -22,6 +22,7 @@ export const ACTION_TYPE = {
GET_BENEFIT_PLAN: 'BENEFIT_PLAN_BENEFIT_PLAN',
CREATE_BENEFIT_PLAN: 'BENEFIT_PLAN_CREATE_BENEFIT_PLAN',
DELETE_BENEFIT_PLAN: 'BENEFIT_PLAN_DELETE_BENEFIT_PLAN',
+ CLOSE_BENEFIT_PLAN: 'BENEFIT_PLAN_CLOSE_BENEFIT_PLAN',
UPDATE_BENEFIT_PLAN: 'BENEFIT_PLAN_UPDATE_BENEFIT_PLAN',
BENEFIT_PLAN_CODE_FIELDS_VALIDATION: 'BENEFIT_PLAN_CODE_FIELDS_VALIDATION',
BENEFIT_PLAN_NAME_FIELDS_VALIDATION: 'BENEFIT_PLAN_NAME_FIELDS_VALIDATION',
diff --git a/src/translations/en.json b/src/translations/en.json
index 53caf49..3c0b34a 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -1,12 +1,16 @@
{
"socialProtection.benefitPlan.delete.confirm.title": "Delete benefit plan {code} {name}",
"socialProtection.benefitPlan.delete.confirm.message": "Are you sure you want to delete the benefit plan?",
+ "socialProtection.benefitPlan.suspend.confirm.title": "Suspend benefit plan {code} {name}",
+ "socialProtection.benefitPlan.suspend.confirm.message": "Are you sure you want to suspend the benefit plan?",
"socialProtection.benefitPlan.delete.mutationLabel": "Delete benefit plan {id}",
"socialProtection.benefitPlan.update.mutationLabel": "Update benefit plan {id}",
"socialProtection.benefitPlan.create.mutationLabel": "Create benefit plan {id}",
"socialProtection.downloadBeneficiaries.mutationLabel": "Download beneficiaries",
"socialProtection.benefitPlan.editButtonTooltip": "Edit",
"socialProtection.benefitPlan.deleteButtonTooltip": "Delete",
+ "socialProtection.benefitPlan.stopButtonTooltip": "Suspend",
+ "socialProtection.stopButtonTooltip": "Suspend",
"socialProtection.benefitPlan.searcherResultsTitle": "{benefitPlansTotalCount} Benefit Plans",
"socialProtection.beneficiaries.searcherResultsTitle": "{beneficiariesTotalCount} Beneficiaries",
"socialProtection.beneficiaries.members.searcherResultsTitle": "{individualsTotalCount} Individuals Found",