Skip to content

Commit

Permalink
Redirect to assignment page when saving finalized IRS plan
Browse files Browse the repository at this point in the history
  • Loading branch information
cKellyDesign committed Oct 17, 2019
1 parent 8ef5142 commit ca3836c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/containers/pages/InterventionPlan/IRS/plan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,11 @@ class IrsPlan extends React.Component<
}

// update state after fetching plan from OpenSRP
if (!newPlan && planById && planById.plan_jurisdictions_ids) {
// update state after saving plan to store
if (
(!newPlan && planById && planById.plan_jurisdictions_ids) ||
(newPlan && planById && newPlan.plan_version !== planById.plan_version)
) {
this.setState({
newPlan: planById,
});
Expand Down Expand Up @@ -2075,6 +2079,18 @@ class IrsPlan extends React.Component<
})
.catch(() => {
this.setState({ isSaveDraftDisabled: false });
})
.finally(() => {
// update state with new plan definition
const { plan_id, plan_status } = newPlanDraft;
const planRecord = extractPlanRecordResponseFromPlanPayload(planPayload);
if (planRecord) {
this.props.fetchPlansActionCreator([planRecord]);
if (plan_status === PlanStatus.ACTIVE) {
// redirect to assingment page
this.props.history.push(`${ASSIGN_IRS_PLAN_URL}/${plan_id}`);
}
}
});
} else {
// save plan-jurisdiction-organization assignments
Expand Down

0 comments on commit ca3836c

Please sign in to comment.