Skip to content

Commit

Permalink
seperate out unique array creation into a new const to make the code …
Browse files Browse the repository at this point in the history
…more readable

lowercase the product title in the cancallation confirmation page title (also means that we can remove a property from the producttype object)
  • Loading branch information
Richard Bangay committed May 17, 2024
1 parent c9c40c6 commit c164820
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
32 changes: 15 additions & 17 deletions client/components/mma/accountoverview/AccountOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,35 +108,33 @@ const AccountOverviewPage = ({ isFromApp }: IsFromAppProps) => {
b.subscription.start.localeCompare(a.subscription.start),
);

const productCategories = [
...new Set(
[...allActiveProductDetails, ...allCancelledProductDetails].map(
(product: ProductDetail | CancelledProductDetail) => {
if (product.mmaCategory === 'recurringSupport') {
return 'subscriptions';
}
return product.mmaCategory;
},
),
),
];
const allProductCategories = [
...allActiveProductDetails,
...allCancelledProductDetails,
].map((product: ProductDetail | CancelledProductDetail) => {
if (product.mmaCategory === 'recurringSupport') {
return 'subscriptions';
}
return product.mmaCategory;
});
const uniqueProductCategories = [...new Set(allProductCategories)];
const appSubscriptions = mpapiResponse.subscriptions.filter(
isValidAppSubscription,
);

if (
featureSwitches.appSubscriptions &&
appSubscriptions.length > 0 &&
!productCategories.includes('subscriptions')
!uniqueProductCategories.includes('subscriptions')
) {
productCategories.push('subscriptions');
uniqueProductCategories.push('subscriptions');
}

if (
singleContributions.length > 0 &&
!productCategories.includes('subscriptions')
!uniqueProductCategories.includes('subscriptions')
) {
productCategories.push('subscriptions');
uniqueProductCategories.push('subscriptions');
}

if (
Expand Down Expand Up @@ -188,7 +186,7 @@ const AccountOverviewPage = ({ isFromApp }: IsFromAppProps) => {
productDetails={allActiveProductDetails}
isFromApp={isFromApp}
/>
{productCategories.map((category) => {
{uniqueProductCategories.map((category) => {
const groupedProductType = GROUPED_PRODUCT_TYPES[category];
const activeProductsInCategory = allActiveProductDetails.filter(
(activeProduct) =>
Expand Down
7 changes: 3 additions & 4 deletions client/components/mma/cancel/CancellationSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ const actuallyCancelled = (
`,
]}
>
{productType.cancellation?.alternateSummaryHeading ||
`Your ${productType.friendlyName(
cancelledProductDetail,
)} is cancelled`}
{`Your ${productType.friendlyName(
cancelledProductDetail,
)} is cancelled`}
</Heading>
{productType.cancellation &&
!productType.cancellation.shouldHideSummaryMainPara && (
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/mocked/parallel-2/cancelSupporterPlus.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('Cancel Supporter Plus', () => {
cy.wait('@get_cancelled_product');

cy.findByRole('heading', {
name: 'Your All-access digital subscription is cancelled',
name: 'Your all-access digital subscription is cancelled',
});

cy.get('@get_cancellation_date.all').should('have.length', 0);
Expand Down
3 changes: 0 additions & 3 deletions shared/productTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ interface CancellationFlowProperties {
startPageOfferEffectiveDateOptions?: true;
hideReasonTitlePrefix?: true;
alternateSummaryMainPara?: string;
alternateSummaryHeading?: string;
shouldHideSummaryMainPara?: true;
summaryReasonSpecificPara: (
reasonId: OptionalCancellationReasonId,
Expand Down Expand Up @@ -636,8 +635,6 @@ export const PRODUCT_TYPES: { [productKey in ProductTypeKeys]: ProductType } = {
cancellation: {
alternateSummaryMainPara:
"This is immediate and you will not be charged again. If you've cancelled within the first 14 days, we'll send you a full refund.",
alternateSummaryHeading:
'Your All-access digital subscription is cancelled',
linkOnProductPage: true,
reasons: shuffledSupporterPlusCancellationReasons,
sfCaseProduct: 'Supporter Plus',
Expand Down

0 comments on commit c164820

Please sign in to comment.