Skip to content

Commit

Permalink
Fix cancel link layout for ManageProductV2
Browse files Browse the repository at this point in the history
  • Loading branch information
KaliedaRik committed Jan 17, 2024
1 parent 83e6464 commit e4f6d11
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import {
until,
} from '@guardian/source-foundations';
import {
Button,
LinkButton,
Stack,
SvgCalendar,
SvgClock,
SvgCreditCard,
} from '@guardian/source-react-components';
import { useLocation, useNavigate } from 'react-router-dom';
import { Link, useLocation, useNavigate } from 'react-router-dom';
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 @@ -52,17 +51,28 @@ import {
} from '@/shared/productTypes';

const subHeadingTitleCss = `
${headline.medium()};
font-weight: bold;
${until.tablet} {
${headline.xxsmall()};
font-weight: bold;
};
`;
${headline.medium()};
font-weight: bold;
${until.tablet} {
${headline.xxsmall()};
font-weight: bold;
};
`;
const subHeadingBorderTopCss = `
margin: 16px 0 16px;
`;

const cancelLinkCss = css`
color: ${palette.brand['400']};
font-weight: bold;
text-decoration: underline;
padding-left: ${space[2]}px;
${until.tablet} {
padding-top: ${space[1]}px;
padding-left: 0;
};
`;

interface InnerContentProps {
manageProductV2Props: WithProductType<ProductType>;
productDetail: ProductDetail;
Expand All @@ -72,7 +82,7 @@ const InnerContent = ({
manageProductV2Props,
productDetail,
}: InnerContentProps) => {
const navigate = useNavigate();
// const navigate = useNavigate();

const mainPlan = getMainPlan(productDetail.subscription);
if (!mainPlan) {
Expand All @@ -93,6 +103,8 @@ const InnerContent = ({

const hasCancellationPending = productDetail.subscription.cancelledAt;

const isSelfServeCancellationAllowed = productDetail.selfServiceCancellation.isAllowed;

const cancelledCopy =
specificProductType.cancelledCopy || groupedProductType.cancelledCopy;

Expand Down Expand Up @@ -244,31 +256,23 @@ const InnerContent = ({
Update payment method
</LinkButton>
)}

<div
css={css`
margin-left: ${space[5]}px;
`}
>
{!hasCancellationPending && (
<Button
priority="subdued"
onClick={() => {
navigate(
'/cancel/' +
specificProductType.urlPart,
{
state: {
productDetail: productDetail,
},
},
);
}}
{!hasCancellationPending && !isSelfServeCancellationAllowed && (
<div
css={css`
display: flex;
align-items: center;
justify-content: center;
`}
>
<Link
css={cancelLinkCss}
to={'/cancel/' + specificProductType.urlPart}
state={{ productDetail: productDetail }}
>
Cancel {groupedProductType.friendlyName()}
</Button>
)}
</div>
Cancel subscription
</Link>
</div>
)}
</div>
</section>
</>
Expand Down
2 changes: 1 addition & 1 deletion shared/featureSwitches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export const featureSwitches: Record<FeatureSwitchName, boolean> = {
exampleFeature: false,
appSubscriptions: true,
supporterPlusUpdateAmount: true,
digisubSave: false,
digisubSave: true,
};

0 comments on commit e4f6d11

Please sign in to comment.