Created a template for the secondary user product card in account overview#1671
Created a template for the secondary user product card in account overview#1671enesihsa wants to merge 13 commits into
Conversation
| </div> | ||
| {groupedProductType.tierLabel && ( | ||
| {isSecondary && | ||
| primarySubscriber && ( // TODO Separate more properly. |
There was a problem hiding this comment.
This is the main addition, makes it look like there is plenty of changes but not really, much is indentation. This conditional section renders the shared subscription details and leave subscription Card.Sections. Currently combined into a single one but there probably is a better way to do this?
| {cardConfig.getBenefitsSectionCopy && nextPaymentDetails && ( | ||
| <Card.Section backgroundColor="#edf5fA" removeBorders> | ||
| <p css={benefitsTextCss}> | ||
| {cardConfig.getBenefitsSectionCopy( | ||
| nextPaymentDetails, | ||
| )} | ||
| {isSecondary && primarySubscriber // TODO should probably find a better way to do this too. | ||
| ? `You're enjoying ${mainPlan.name} as part of a shared subscription.` | ||
| : cardConfig.getBenefitsSectionCopy( | ||
| nextPaymentDetails, | ||
| )} | ||
| </p> |
There was a problem hiding this comment.
It's possible that nextPaymentDetails will not exist, so
cardConfig.getBenefitsSectionCopy && nextPaymentDetails
Will always test false. You could do something like:
cardConfig.getBenefitsSectionCopy && (nextPaymentDetails || isSecondary) && (
And then
isSecondary ? "you are enjoying copy" : cardConfig.getBenefitsSectionCopy()
There was a problem hiding this comment.
Ah thanks, missed this one. Another question I had was would it be possible to have the secondary user details in the getBenefitsSectionCopy too (or a more generic way of fetching them), currently it has one for each Zuora subscription type I think, but there are exceptions now for secondary users and GW Gift subscriptions.
j-ruda-guardian
left a comment
There was a problem hiding this comment.
I think this looks good. May I ask you for a change that will make reviewing this files a lot easier:
Please, take the new secondary user card and extract it to a new file (This ProductCard file is already more than crowded enough) and then import it and render it conditionally like you are doing. That might solve this indentation nightmare and will also make the whole thing easier to review!
nice work, thank you!
044e650 to
a756302
Compare
16d4f8c to
0567ca5
Compare
| /> | ||
| <JoinDateRow | ||
| }) => | ||
| !primaryUser && ( |
There was a problem hiding this comment.
I am really confused as to why this keeps causing the same issue. At least it's much more manageable here and easier to verify that nothing actually changes apart from the addition of this condition.
| http.get('/api/me/one-off-contributions', () => { | ||
| return HttpResponse.json([]); | ||
| }), | ||
| http.get('/api/me/secondary-account', () => { |
| uniqueProductCategories.push('subscriptions'); | ||
| } | ||
|
|
||
| // TODO we can add secondary user product card to subscriptions but will need to update the type definition to make it work. |
There was a problem hiding this comment.
This would allow us to show shared subscriptions alongside other subscriptions. Current setup shows it in a separate section.
|
|
||
| export const multipleAccountsApiHandler = proxyApiHandler( | ||
| // TODO format differs from other API hosts? | ||
| conf.STAGE === 'PROD' |
There was a problem hiding this comment.
4e9357b to
6563f63
Compare
| > | ||
| <p css={benefitsTextCss}> | ||
| {cardConfig.getBenefitsSectionCopy(nextPaymentDetails)} | ||
| {nextPaymentDetails |
There was a problem hiding this comment.
This has to be done because secondary account benefits copy text cannot take in a nextPaymentDetails since it is not used for anything in the text. All other subscription product cards show some information about pricing and next payment dates.
| const guardianWeeklyBenefitsCopy = (npd: NextPaymentDetails) => | ||
| `You're subscribed to The Guardian Weekly for ${npd.currentPriceValue} per ${npd.paymentInterval} and receive a curated news magazine featuring our best global journalism in print, as well as unlimited access to our full suite of digital benefits.`; | ||
|
|
||
| // TODO This not having npd has been quite a problem. Current solution is a bit hacky. |
There was a problem hiding this comment.
6563f63 to
6fc8b9a
Compare
Current situation/background
This PR creates the necessary product card sections and benefits copies for the secondary user account benefits as part of the multiple accounts initiative.
What does this PR change?
SecondaryAccountCard.tsxto render the shared subscription product card on account overview without depending on a ProductDetail response since the endpoint for secondary accounts will not return a detailed subscription data.Next steps/further info
a. There is a guard for testing in CODE and DEV with a url parameter.