Skip to content
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

DigiSub routes and cancellation reasons #1275

Merged
merged 22 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4236b9b
Routes added for new digi sub journey on MMA
charleycampbell Dec 4, 2023
a870572
Added in check for digital url to direct to the manage product v2 screen
charleycampbell Dec 5, 2023
87b8f93
Flow from account overview works up until continue to cancel which cu…
charleycampbell Dec 7, 2023
bfbbc2d
Flow working to cancel dig sub!
charleycampbell Dec 7, 2023
504ec27
remove condition from MMAPages
charleycampbell Dec 7, 2023
19664e4
link on V2 is now corrected using the shared link css
charleycampbell Dec 7, 2023
1d3193e
new reasons page to complete the cancellation journey
charleycampbell Dec 7, 2023
d9b088d
Merge branch 'main' into cc/digisub/journey-routes
charleycampbell Dec 7, 2023
a0b1166
Cypress tests added but need a bit of work once the new endpoint is l…
charleycampbell Dec 7, 2023
bfedc0d
commented out test steps
charleycampbell Dec 7, 2023
c0c498f
add digipack to 'getNextRoute' on landing
andrewHEguardian Dec 8, 2023
b05b608
refactor links and add feature switch
andrewHEguardian Dec 8, 2023
0c54e2e
use relative paths in navigation
andrewHEguardian Dec 8, 2023
86f274b
style cancellation message
andrewHEguardian Dec 11, 2023
3cdd392
add new journey complete url
andrewHEguardian Dec 11, 2023
8aae40d
turn featureSwitch off
andrewHEguardian Dec 11, 2023
16d9ab2
make Reasons page generic
andrewHEguardian Dec 11, 2023
437c064
use group friendly name
andrewHEguardian Dec 11, 2023
2494715
refactor: remove extra braces
andrewHEguardian Dec 11, 2023
ddc9b9b
update path after Submit reason
andrewHEguardian Dec 12, 2023
f5921ce
refactored to use useNavigate throughout instead of Navigate
charleycampbell Dec 12, 2023
bbe3c8c
Merge remote-tracking branch 'origin/cc/digisub/journey-routes' into …
charleycampbell Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 70 additions & 13 deletions client/components/mma/MMAPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
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,
Expand Down Expand Up @@ -33,7 +36,7 @@
import { Maintenance } from './maintenance/Maintenance';
import { MMAPageSkeleton } from './MMAPageSkeleton';

const record = (event: any) => {

Check warning on line 39 in client/components/mma/MMAPage.tsx

View workflow job for this annotation

GitHub Actions / manage-frontend build

Unexpected any. Specify a different type
if (window.guardian?.ophan?.record) {
window.guardian.ophan.record(event);
}
Expand Down Expand Up @@ -66,6 +69,11 @@
/* webpackChunkName: "ManageProduct" */ './accountoverview/ManageProduct'
).then(({ ManageProduct }) => ({ default: ManageProduct })),
);
const ManageProductV2 = lazy(() =>
import(
/* webpackChunkName: "ManageProduct" */ './accountoverview/manageProducts/ManageProductV2'
).then(({ ManageProductV2 }) => ({ default: ManageProductV2 })),
);
const CancellationContainer = lazy(() =>
import(
/* webpackChunkName: "Cancellation" */ './cancel/CancellationContainer'
Expand Down Expand Up @@ -134,7 +142,7 @@

const SelectReason = lazy(() =>
import(
/* webpackChunkName: "Cancellation" */ './cancel/cancellationSaves/membership/SelectReason'
/* webpackChunkName: "Cancellation" */ './cancel/cancellationSaves/SelectReason'
).then(({ SelectReason }) => ({
default: SelectReason,
})),
Expand Down Expand Up @@ -164,6 +172,30 @@
})),
);

const ConfirmDigiSubCancellation = lazy(() =>
import(
/* webpackChunkName: "Cancellation" */ './cancel/cancellationSaves/digipack/ConfirmDigiSubCancellation'
).then(({ ConfirmDigiSubCancellation: ConfirmDigiSubCancellation }) => ({
default: ConfirmDigiSubCancellation,
})),
);

const DigiSubThankYouOffer = lazy(() =>
import(
/* webpackChunkName: "Cancellation" */ './cancel/cancellationSaves/digipack/ThankYouOffer'
).then(({ ThankYouOffer: ThankYouOffer }) => ({
default: ThankYouOffer,
})),
);

const ConfirmDigiSubDiscount = lazy(() =>
import(
/* webpackChunkName: "Cancellation" */ './cancel/cancellationSaves/digipack/DigiSubDiscountConfirm'
).then(({ DigiSubDiscountConfirm: DigiSubDiscountConfirm }) => ({
default: DigiSubDiscountConfirm,
})),
);

const PaymentDetailUpdateContainer = lazy(() =>
import(
/* webpackChunkName: "PaymentDetailUpdate" */ './paymentUpdate/PaymentDetailUpdateContainer'
Expand Down Expand Up @@ -475,17 +507,29 @@
</Route>
))}
{Object.values(PRODUCT_TYPES).map(
(productType: ProductType) => (
<Route
key={productType.urlPart}
path={`/${productType.urlPart}`}
element={
<ManageProduct
productType={productType}
/>
}
/>
),
(productType: ProductType) =>
featureSwitches.digisubSave &&
productType.productType === 'digipack' ? (
<Route
key={productType.urlPart}
path={`/${productType.urlPart}`}
element={
<ManageProductV2
productType={productType}
/>
}
/>
) : (
<Route
key={productType.urlPart}
path={`/${productType.urlPart}`}
element={
<ManageProduct
productType={productType}
/>
}
/>
),
)}
{Object.values(PRODUCT_TYPES)
.filter(hasDeliveryFlow)
Expand Down Expand Up @@ -658,6 +702,19 @@
path="switch-thank-you"
element={<SwitchThankYou />}
/>

<Route
path="confirm-cancel"
element={<ConfirmDigiSubCancellation />}
/>
<Route
path="confirm-discount"
element={<ConfirmDigiSubDiscount />}
/>
<Route
path="discount-offer"
element={<DigiSubThankYouOffer />}
/>
</Route>
),
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { user } from '../../../fixtures/user';
import { AccountOverview } from './AccountOverview';

featureSwitches['appSubscriptions'] = true;
featureSwitches['singleContributions'] = true;

export default {
title: 'Pages/AccountOverview',
Expand Down
2 changes: 1 addition & 1 deletion client/components/mma/accountoverview/ManageProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from '@guardian/source-foundations';
import { useState } from 'react';
import { Link, Navigate, useLocation } from 'react-router-dom';
import { featureSwitches } from '@/shared/featureSwitches';
import { cancellationFormatDate } from '../../../../shared/dates';
import { featureSwitches } from '../../../../shared/featureSwitches';
import type {
MembersDataApiResponse,
ProductDetail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {
until,
} from '@guardian/source-foundations';
import {
Button,
LinkButton,
Stack,
SvgCalendar,
SvgClock,
SvgCreditCard,
} from '@guardian/source-react-components';
import { Link, Navigate, useLocation } from 'react-router-dom';
import { Navigate, useLocation, useNavigate } from 'react-router-dom';
charleycampbell marked this conversation as resolved.
Show resolved Hide resolved
import { PageContainer } from '@/client/components/mma/Page';
import { ErrorIcon } from '@/client/components/mma/shared/assets/ErrorIcon';
import { JsonResponseHandler } from '@/client/components/mma/shared/asyncComponents/DefaultApiResponseHandler';
Expand Down Expand Up @@ -71,6 +72,8 @@ const InnerContent = ({
manageProductV2Props,
productDetail,
}: InnerContentProps) => {
const navigate = useNavigate();

const mainPlan = getMainPlan(productDetail.subscription);
if (!mainPlan) {
throw new Error('mainPlan does not exist in manageProductV2 page');
Expand Down Expand Up @@ -248,11 +251,17 @@ const InnerContent = ({
`}
>
{!hasCancellationPending && (
<CancellationCTA
productDetail={productDetail}
friendlyName={groupedProductType.friendlyName()}
specificProductType={specificProductType}
/>
<Button
priority="subdued"
onClick={() => {
navigate(
'/cancel/' +
specificProductType.urlPart,
);
}}
>
Cancel {groupedProductType.friendlyName()}
</Button>
)}
</div>
</div>
Expand All @@ -261,55 +270,6 @@ const InnerContent = ({
);
};

interface CancellationCTAProps {
andrewHEguardian marked this conversation as resolved.
Show resolved Hide resolved
productDetail: ProductDetail;
friendlyName: string;
specificProductType: ProductType;
}

const CancellationCTA = (props: CancellationCTAProps) => {
const shouldContactUsToCancel =
!props.productDetail.selfServiceCancellation.isAllowed ||
!props.specificProductType.cancellation;
return (
<>
{shouldContactUsToCancel && (
<div
css={css`
${textSans.medium()};
color: ${palette.neutral[46]};
margin-top: 16px;
justify-content: center;
`}
>
Would you like to cancel your {props.friendlyName}?
<Link
css={css`
${textSans.medium()};
color: ${palette.brand[400]};
font-weight: 700;
text-decoration-line: underline;
justify-content: center;
margin-left: 5px;
`}
to={'/cancel/' + props.specificProductType.urlPart}
state={{ productDetail: props.productDetail }}
>
Contact us
</Link>
</div>
)}

{!shouldContactUsToCancel && (
<Link to={'/cancel/' + props.specificProductType.urlPart}>
{' '}
Cancel {props.friendlyName}{' '}
</Link>
)}
</>
);
};

interface ManageProductV2RouterState {
productDetail: ProductDetail;
}
Expand Down
20 changes: 16 additions & 4 deletions client/components/mma/cancel/CancellationSaveEligibilityCheck.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
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,
CancellationRouterState,
} 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;
Expand All @@ -20,10 +35,7 @@ export const CancellationSaveEligibilityCheck = () => {
return <Navigate to="/" />;
}

if (
!routerState?.dontShowOffer &&
productDetail.mmaCategory === 'membership'
) {
if (!routerState?.dontShowOffer && productHasSaveJourney(productDetail)) {
return <Navigate to="./landing" />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function getNextRoute(productToCancel: ProductDetail): string {
case 'membership': {
return '../details';
}
case 'digipack': {
return '../discount-offer';
}
default: {
return '/';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { ConfirmMembershipCancellation } from './membership/ConfirmMembershipCan
import { ContinueMembershipConfirmation } from './membership/ContinueMembershipConfirmation';
import { MembershipSwitch } from './membership/MembershipSwitch';
import { SaveOptions } from './membership/SaveOptions';
import { SelectReason } from './membership/SelectReason';
import { SwitchThankYou } from './membership/SwitchThankYou';
import { ValueOfSupport } from './membership/ValueOfSupport';
import { SelectReason } from './SelectReason';

export default {
title: 'Pages/CancellationSave',
Expand Down
Loading
Loading