diff --git a/client/components/mma/MMAPage.tsx b/client/components/mma/MMAPage.tsx index 6a8540325..845820e90 100644 --- a/client/components/mma/MMAPage.tsx +++ b/client/components/mma/MMAPage.tsx @@ -4,7 +4,10 @@ import { breakpoints, from, space } from '@guardian/source-foundations'; import type { ReactNode } from 'react'; import { lazy, Suspense, useEffect, useState } from 'react'; import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'; -import { initFeatureSwitchUrlParamOverride } from '../../../shared/featureSwitches'; +import { + featureSwitches, + initFeatureSwitchUrlParamOverride, +} from '../../../shared/featureSwitches'; import type { ProductType, ProductTypeWithDeliveryRecordsProperties, @@ -513,7 +516,8 @@ const MMARouter = () => { ))} {Object.values(PRODUCT_TYPES).map( (productType: ProductType) => - productType.urlPart === 'digital' ? ( + featureSwitches.digisubSave && + productType.productType === 'digipack' ? ( { + const navigate = useNavigate(); + const mainPlan = getMainPlan(productDetail.subscription); if (!mainPlan) { throw new Error('mainPlan does not exist in manageProductV2 page'); @@ -249,11 +251,17 @@ const InnerContent = ({ `} > {!hasCancellationPending && ( - + )} @@ -262,22 +270,6 @@ const InnerContent = ({ ); }; -interface CancellationCTAProps { - productDetail: ProductDetail; - friendlyName: string; - specificProductType: ProductType; -} - -const CancellationCTA = (props: CancellationCTAProps) => { - return ( - <> - - Cancel {props.friendlyName}{' '} - - - ); -}; - interface ManageProductV2RouterState { productDetail: ProductDetail; } diff --git a/client/components/mma/cancel/CancellationSaveEligibilityCheck.tsx b/client/components/mma/cancel/CancellationSaveEligibilityCheck.tsx index 7785cdd08..93923a6b4 100644 --- a/client/components/mma/cancel/CancellationSaveEligibilityCheck.tsx +++ b/client/components/mma/cancel/CancellationSaveEligibilityCheck.tsx @@ -1,5 +1,10 @@ import { useContext } from 'react'; import { Navigate, useLocation } from 'react-router-dom'; +import { featureSwitches } from '@/shared/featureSwitches'; +import { + getSpecificProductTypeFromProduct, + type ProductDetail, +} from '@/shared/productResponse'; import { CancellationContext } from './CancellationContainer'; import type { CancellationContextInterface, @@ -7,6 +12,16 @@ import type { } from './CancellationContainer'; import { CancellationReasonSelection } from './CancellationReasonSelection'; +function productHasSaveJourney(productToCancel: ProductDetail): boolean { + const specificProductTypeKey = + getSpecificProductTypeFromProduct(productToCancel).productType; + + return ( + specificProductTypeKey === 'membership' || + (featureSwitches.digisubSave && specificProductTypeKey === 'digipack') + ); +} + export const CancellationSaveEligibilityCheck = () => { const location = useLocation(); const routerState = location.state as CancellationRouterState; @@ -20,10 +35,7 @@ export const CancellationSaveEligibilityCheck = () => { return ; } - if ( - !routerState?.dontShowOffer && - productDetail.mmaCategory === 'membership' - ) { + if (!routerState?.dontShowOffer && productHasSaveJourney(productDetail)) { return ; } diff --git a/client/components/mma/identity/emailAndMarketing/EmailAndMarketing.stories.tsx b/client/components/mma/identity/emailAndMarketing/EmailAndMarketing.stories.tsx index 718b21735..46efb9e54 100644 --- a/client/components/mma/identity/emailAndMarketing/EmailAndMarketing.stories.tsx +++ b/client/components/mma/identity/emailAndMarketing/EmailAndMarketing.stories.tsx @@ -142,8 +142,6 @@ export const WithIAP: StoryObj = { export const WithSingleContribution: StoryObj = { render: () => { - featureSwitches['singleContributions'] = true; - return ; }, diff --git a/shared/featureSwitches.ts b/shared/featureSwitches.ts index 40d066d34..ad57d869f 100644 --- a/shared/featureSwitches.ts +++ b/shared/featureSwitches.ts @@ -4,7 +4,7 @@ export const initFeatureSwitchUrlParamOverride = () => { if (param) { for (const [key, value] of Object.entries(featureSwitches)) { if (!value) { - featureSwitches[key] = param === key; + featureSwitches[key as FeatureSwitchName] = param === key; } } } @@ -22,8 +22,16 @@ export const initFeatureSwitchUrlParamOverride = () => { * name provided then the function will return false and the feature switch * will be set to off. */ -export const featureSwitches: Record = { + +type FeatureSwitchName = + | 'exampleFeature' + | 'appSubscriptions' + | 'supporterPlusUpdateAmount' + | 'digisubSave'; + +export const featureSwitches: Record = { exampleFeature: false, appSubscriptions: true, supporterPlusUpdateAmount: true, + digisubSave: true, };