-
Notifications
You must be signed in to change notification settings - Fork 4
Created a template for the secondary user product card in account overview #1671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
enesihsa
wants to merge
13
commits into
main
Choose a base branch
from
ea/multiple-accounts/secondary-user-account-overview
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
855a631
Created a template for the secondary user product card in account ove…
enesihsa d5eb749
Moved Secondary Account product card sections to a separate file
enesihsa 28796b4
Fixed missed git rebase issues
enesihsa 2b367e6
Solved some conflicts attempting to rebase
enesihsa 507c6fc
Removed unusued element, ternary, and minor css edit
enesihsa b18b6ce
Plugged in the mocked server API calls
enesihsa f399a84
Removed primary subscriber details from ProductCard
enesihsa 35a1515
Removed primaryUser from ProductDetail
enesihsa b629614
Remove last name from the copy text and types.
enesihsa 6fc8b9a
Changed API endpoints and data schema for responses
enesihsa c1a5b6b
Merge branch 'main' into ea/multiple-accounts/secondary-user-account-…
enesihsa 7ec2428
Removed primaryUser from Subscription
enesihsa 151751c
Product title copy change
enesihsa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import type { FetchUpgradePreviewParams } from '@/client/utilities/hooks/useUpgr | |
| import { parseDate } from '@/shared/dates'; | ||
| import type { | ||
| MembersDataApiUser, | ||
| MultipleAccountsPrimaryUser, | ||
| PaidSubscriptionPlan, | ||
| ProductDetail, | ||
| SubscriptionPlan, | ||
|
|
@@ -29,6 +30,7 @@ import type { ProductCardConfiguration } from './ProductCardConfiguration'; | |
| import { | ||
| benefitsSectionBackgroundColour, | ||
| benefitsTextCss, | ||
| centeredActionCss, | ||
| centeredButtonCss, | ||
| giftRibbonColour, | ||
| giftRibbonCopyColour, | ||
|
|
@@ -37,6 +39,8 @@ import { | |
| productCardTitleCss, | ||
| productDetailLayoutCss, | ||
| sectionHeadingCss, | ||
| sharedMembershipLeaveButtonCss, | ||
| sharedMembershipTextCss, | ||
| } from './ProductCardStyles'; | ||
|
|
||
| const NewPriceAlert = () => { | ||
|
|
@@ -92,21 +96,25 @@ export const BenefitsCopyAndToggle = ({ | |
| mainPlan, | ||
| nextPaymentDetails, | ||
| overrideBenefits, | ||
| overrideBenefitsText, | ||
| }: { | ||
| cardConfig: ProductCardConfiguration; | ||
| specificProductType: ProductType; | ||
| mainPlan: SubscriptionPlan; | ||
| nextPaymentDetails?: NextPaymentDetails | undefined; | ||
| nextPaymentDetails?: NextPaymentDetails; | ||
| overrideBenefits?: ProductBenefit[]; | ||
| overrideBenefitsText?: string; | ||
| }) => | ||
| cardConfig.getBenefitsSectionCopy && | ||
| nextPaymentDetails && ( | ||
| (nextPaymentDetails || overrideBenefitsText) && ( | ||
| <Card.Section | ||
| backgroundColor={benefitsSectionBackgroundColour} | ||
| removeBorders | ||
| > | ||
| <p css={benefitsTextCss}> | ||
| {cardConfig.getBenefitsSectionCopy(nextPaymentDetails)} | ||
| {nextPaymentDetails | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
| ? cardConfig.getBenefitsSectionCopy(nextPaymentDetails) | ||
| : overrideBenefitsText} | ||
| </p> | ||
| <BenefitsToggle | ||
| productType={specificProductType.productType} | ||
|
|
@@ -135,6 +143,42 @@ export const GuardianAdLiteCopy = ({ | |
| </Card.Section> | ||
| ); | ||
|
|
||
| export const SecondaryUserSubscriptionDetails = ({ | ||
| subscriptionName, | ||
| primarySubscriber, | ||
| }: { | ||
| subscriptionName: string; | ||
| primarySubscriber: MultipleAccountsPrimaryUser | undefined; | ||
| }) => | ||
| primarySubscriber && ( | ||
| <Card.Section> | ||
| <div css={productDetailLayoutCss}> | ||
| <div> | ||
| <h4 css={sectionHeadingCss}>Subscription details</h4> | ||
| <p css={sharedMembershipTextCss}> | ||
| Subscription: {subscriptionName} shared subscription{' '} | ||
| <br /> | ||
| <br /> | ||
| You’ve been given access by{' '} | ||
| {primarySubscriber.firstName}. Your account and activity | ||
| are private and not shared with the subscription owner. | ||
| </p> | ||
| </div> | ||
| <div css={centeredActionCss}> | ||
| <Button | ||
| aria-label={`${subscriptionName} : Leave shared subscription`} | ||
| size="small" | ||
| priority="tertiary" | ||
| cssOverrides={sharedMembershipLeaveButtonCss} | ||
| onClick={() => undefined} | ||
| > | ||
| Manage support | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </Card.Section> | ||
| ); | ||
|
|
||
| const StartDateRow = ({ | ||
| subscriptionStartDate, | ||
| shouldShowStartDate, | ||
|
|
||
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
60 changes: 60 additions & 0 deletions
60
client/components/mma/accountoverview/SecondaryAccountCard.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import type { MultipleAccountsApiResponse } from '@/shared/productResponse'; | ||
| import { getSpecificProductTypeFromProductKey } from '@/shared/productResponse'; | ||
| import { Card } from '../shared/Card'; | ||
| import { | ||
| getSecondaryUserBenefitsCopy, | ||
| secondaryUserBenefitsCopy, | ||
| } from './ProductCardConfiguration'; | ||
| import { | ||
| BenefitsCopyAndToggle, | ||
| ProductCardHeader, | ||
| SecondaryUserSubscriptionDetails, | ||
| } from './ProductCardSections'; | ||
|
|
||
| export const SecondaryAccountProductCard = ({ | ||
| maapiResponse, | ||
| }: { | ||
| maapiResponse: MultipleAccountsApiResponse; | ||
| }) => { | ||
| // TODO: This is a placeholder. We will likely need to adjust this. | ||
|
|
||
| // TODO Hard-coded atm | ||
| const specificProductType = | ||
| getSpecificProductTypeFromProductKey('Digital Pack'); | ||
| const mainPlan = { | ||
| name: specificProductType.friendlyName, | ||
| shouldBeVisible: true, | ||
| }; | ||
| if (!mainPlan) { | ||
| throw new Error('mainPlan does not exist in SecondaryAccountCard'); | ||
| } | ||
| const productTitle = | ||
| specificProductType.productTitle(mainPlan) + ' shared subscription'; | ||
| const cardConfig = getSecondaryUserBenefitsCopy; | ||
| const overrideBenefitsText = secondaryUserBenefitsCopy(); | ||
|
|
||
| return ( | ||
| <> | ||
| {maapiResponse.primaryUsers.map((primaryUser, index) => ( | ||
| <Card key={index}> | ||
| <ProductCardHeader | ||
| cardConfig={cardConfig} | ||
| productTitle={productTitle} | ||
| /> | ||
|
|
||
| <BenefitsCopyAndToggle | ||
| cardConfig={cardConfig} | ||
| specificProductType={specificProductType} | ||
| mainPlan={mainPlan} | ||
| overrideBenefitsText={overrideBenefitsText} | ||
| /> | ||
|
|
||
| <SecondaryUserSubscriptionDetails | ||
| subscriptionName={productTitle} | ||
| primarySubscriber={primaryUser} | ||
| /> | ||
| </Card> | ||
| ))} | ||
| </> | ||
| ); | ||
| }; |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/guardian/manage-frontend/pull/1671/changes#r3535584027