From ddc9b9bd04d1f758d88038d16a50ee5d17fb9af5 Mon Sep 17 00:00:00 2001 From: Andrew Howe-Ely <114918544+andrewHEguardian@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:52:32 +0000 Subject: [PATCH 1/2] update path after Submit reason --- client/components/mma/cancel/cancellationSaves/SelectReason.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/mma/cancel/cancellationSaves/SelectReason.tsx b/client/components/mma/cancel/cancellationSaves/SelectReason.tsx index 68713f1e2..b3f92a1ec 100644 --- a/client/components/mma/cancel/cancellationSaves/SelectReason.tsx +++ b/client/components/mma/cancel/cancellationSaves/SelectReason.tsx @@ -216,7 +216,7 @@ export const SelectReason = () => { const canContinue = !!selectedReasonId.length; if (canContinue) { await postReason(); - navigate(navigateToReminder ? '../reminder' : './', { + navigate(navigateToReminder ? '../reminder' : '/', { state: { selectedReasonId, }, From f5921cebb6ff31d70de84ee1507f2dedab53b91f Mon Sep 17 00:00:00 2001 From: Charley_Campbell Date: Tue, 12 Dec 2023 16:21:50 +0000 Subject: [PATCH 2/2] refactored to use useNavigate throughout instead of Navigate --- .../mma/accountoverview/manageProducts/ManageProductV2.tsx | 7 +++++-- cypress/e2e/parallel-2/digisubSave.cy.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/components/mma/accountoverview/manageProducts/ManageProductV2.tsx b/client/components/mma/accountoverview/manageProducts/ManageProductV2.tsx index 06ff682cd..d7a32b1ee 100644 --- a/client/components/mma/accountoverview/manageProducts/ManageProductV2.tsx +++ b/client/components/mma/accountoverview/manageProducts/ManageProductV2.tsx @@ -14,7 +14,7 @@ import { SvgClock, SvgCreditCard, } from '@guardian/source-react-components'; -import { Navigate, useLocation, useNavigate } from 'react-router-dom'; +import { 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'; @@ -275,6 +275,8 @@ interface ManageProductV2RouterState { } const AsyncLoadedInnerContent = (props: WithProductType) => { + const navigate = useNavigate(); + const request = createProductDetailFetcher( props.productType.allProductsProductTypeFilterString, ); @@ -292,7 +294,8 @@ const AsyncLoadedInnerContent = (props: WithProductType) => { } if (data == null || data.products.length == 0) { - return ; + navigate('/'); + return null; } const productDetail = data.products.filter(isProduct)[0]; diff --git a/cypress/e2e/parallel-2/digisubSave.cy.ts b/cypress/e2e/parallel-2/digisubSave.cy.ts index 133a7a080..65e88345e 100644 --- a/cypress/e2e/parallel-2/digisubSave.cy.ts +++ b/cypress/e2e/parallel-2/digisubSave.cy.ts @@ -87,7 +87,7 @@ describe('Cancel digi sub', () => { }).click(); //TODO Below can be implemented once new endpoint is completed - //cy.findByText('Discount confirmed');m + //cy.findByText('Discount confirmed'); //cy.go('back'); //cy.findByRole('heading', { name: 'Account overview' }).should('exist'); });