Fix undefined Benefit Product on payment plan listing#109
Open
Shahzaibahmad97 wants to merge 1 commit intodevelopfrom
Open
Fix undefined Benefit Product on payment plan listing#109Shahzaibahmad97 wants to merge 1 commit intodevelopfrom
Shahzaibahmad97 wants to merge 1 commit intodevelopfrom
Conversation
The PAYMENTPLANS list reducer was passing benefitPlan straight through without parsing. Because the backend serialises this field as a graphene JSONString wrapping a json.dumps(...) result, the value arrives at the frontend as a double-encoded JSON string. PaymentPlanSearcher tried to compensate with an inline single JSON.parse, but on a double-encoded input that produces another string (not an object), so BenefitPlanPicker rendered the option label as "undefined undefined" on the very first render. Any subsequent state change re-ran the inline parse on the now single-encoded string and produced the object, masking the bug. Parse benefitPlan in the reducer (double parse, mirroring the CONTRIBUTIONPLAN_CONTRIBUTIONPLANS_RESP handler) so consumers receive a proper object on the first render. The defensive inline parse in the searcher becomes a no-op for this code path.
|
68 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
On the Payment Plans listing page (
/front/paymentPlans), the Benefit Product column rendered each row's program picker label as "undefined…" on the very first render after the search results came in. Any subsequent state change (filter input, sort, etc.) made the value appear correctly, which made the bug look intermittent.Root cause: the backend serialises the
benefitPlanfield ofpaymentPlanas a grapheneJSONStringwrapping ajson.dumps(...)result, so the value arrives at the frontend double-encoded. The list reducer (CONTRIBUTIONPLAN_PAYMENTPLANS_RESP) was passing it through unparsed, whilePaymentPlanSearcher.itemFormattersonly did a single inlineJSON.parse. Single-parsing a double-encoded string produces another string (not an object), soBenefitPlanPickerrendered${value.code} ${value.name}as"undefined undefined". A second render re-ran the inline parse on the now-single-encoded string and produced the object — masking the bug after any user interaction.This PR parses
benefitPlanonce in the reducer (double parse), mirroring the existingCONTRIBUTIONPLAN_CONTRIBUTIONPLANS_RESPhandler, so consumers receive a proper object on the first render.Type of Change
Related Issue(s) / Task(s)
E2E Payment Tests
Changes
benefitPlan(double parse, with null guard) inCONTRIBUTIONPLAN_PAYMENTPLANS_RESPso the list reducer produces objects withcode/namealready accessible.PaymentPlanSearcher.js— its existing defensive inline parse becomes a no-op when the value is already an object.Behaviour Before / After
/front/paymentPlansDemo
To be added after manual verification.
Checklist
CONTRIBUTIONPLAN_CONTRIBUTIONPLANS_RESPreducer handlerbenefitPlanis guarded (returnsnullinstead of throwing onJSON.parse)PaymentPlanSearcheris preserved as a no-op fallback