diff --git a/src/reducer.js b/src/reducer.js index 01fea83..55887dc 100644 --- a/src/reducer.js +++ b/src/reducer.js @@ -281,7 +281,16 @@ function reducer( ...state, fetchingPaymentPlans: false, fetchedPaymentPlans: true, - paymentPlans: parseData(action.payload.data.paymentPlan), + paymentPlans: parseData(action.payload.data.paymentPlan)?.map((paymentPlan) => ({ + ...paymentPlan, + // benefitPlan is double-encoded by the backend (graphene JSONString + // wraps a json.dumps(...) result). Parse it here so consumers like + // PaymentPlanSearcher and the BenefitPlanPicker receive an object + // and can read code/name on the very first render. + benefitPlan: !!paymentPlan.benefitPlan + ? JSON.parse(JSON.parse(paymentPlan.benefitPlan)) + : null, + })), paymentPlansPageInfo: pageInfo(action.payload.data.paymentPlan), paymentPlansTotalCount: !!action.payload.data.paymentPlan ? action.payload.data.paymentPlan.totalCount