diff --git a/src/apps/routers.js b/src/apps/routers.js index 3eaa198bc19..7105da04ce0 100644 --- a/src/apps/routers.js +++ b/src/apps/routers.js @@ -26,7 +26,8 @@ const reactRoutes = [ '/export/:exportId/details', '/export/:exportId/delete', '/exportwins', - '/exportwins/create', + '/companies/:companyId/exportwins/create', + '/companies/:companyId/export/:exportId/exportwins/create', '/exportwins/:winId/edit', '/exportwins/won', '/exportwins/sent', diff --git a/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx b/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx index 8bdcbd24528..1c07208b458 100644 --- a/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx +++ b/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx @@ -1,9 +1,7 @@ import React from 'react' -import { useLocation } from 'react-router-dom' import { H3 } from '@govuk-react/heading' import ResourceOptionsField from '../../../components/Form/elements/ResourceOptionsField' -import { getQueryParamsFromLocation } from '../../../../client/utils/url' import { Step, FieldTypeahead } from '../../../components' import { idNamesToValueLabels } from '../../../utils' import { StyledHintParagraph } from './styled' @@ -15,11 +13,7 @@ import { BusinessPotentialResource, } from '../../../components/Resource' -const CustomerDetailsStep = () => { - const location = useLocation() - const queryParams = getQueryParamsFromLocation(location) - const companyId = queryParams.company - +const CustomerDetailsStep = ({ companyId }) => { return (

Customer details

diff --git a/src/client/modules/ExportWins/Form/ExportWinForm.jsx b/src/client/modules/ExportWins/Form/ExportWinForm.jsx index 8f74386b28d..c79b25354dc 100644 --- a/src/client/modules/ExportWins/Form/ExportWinForm.jsx +++ b/src/client/modules/ExportWins/Form/ExportWinForm.jsx @@ -22,6 +22,7 @@ const CompanyName = ({ companyId }) => ( const ExportWinForm = ({ title, + exportId, companyId, exportWinId, initialValuesTaskName, @@ -29,7 +30,12 @@ const ExportWinForm = ({ csrfToken, currentAdviserId, }) => { - const stepProps = { isEditing: !!exportWinId } + const stepProps = { + isEditing: !!exportWinId, + exportId, + companyId, + exportWinId, + } return ( { +const OfficerDetailsStep = ({ companyId, exportId, exportWinId }) => { const { values } = useFormContext() - const location = useLocation() - const queryParams = getQueryParamsFromLocation(location) - return ( diff --git a/src/client/modules/ExportWins/Form/index.jsx b/src/client/modules/ExportWins/Form/index.jsx index f3c46f1b6e2..17cf4318d87 100644 --- a/src/client/modules/ExportWins/Form/index.jsx +++ b/src/client/modules/ExportWins/Form/index.jsx @@ -1,36 +1,31 @@ import React from 'react' import { TASK_GET_EXPORT_WIN, TASK_GET_EXPORT_PROJECT } from './state' -import { getQueryParamsFromLocation } from '../../../utils/url' import ExportWinForm from './ExportWinForm' // If we're converting an export project to an export win // then we'll have the export id, otherwise we're creating // the export win from scratch. -export const CreateExportWin = ({ location }) => { - const queryParams = getQueryParamsFromLocation(location) +export const CreateExportWin = ({ match }) => { + const exportId = match.params.exportId return ( ) } // Here we're editing an existing win so we'll have the // export win id. -export const EditExportWin = ({ location, match }) => { - const queryParams = getQueryParamsFromLocation(location) +export const EditExportWin = ({ match }) => { return ( - `/exportwins/create?company=${companyId}&export=${exportId}`, + create: url('/companies', '/:companyId/exportwins/create'), + createFromExport: url( + '/companies', + '/:companyId/export/:exportId/exportwins/create' + ), customerFeedback: url('/exportwins', '/:winId/customer-feedback'), }, overview: { diff --git a/test/a11y/cypress/config/urlTestExclusions.js b/test/a11y/cypress/config/urlTestExclusions.js index 1e5323540a2..4860c3b5809 100644 --- a/test/a11y/cypress/config/urlTestExclusions.js +++ b/test/a11y/cypress/config/urlTestExclusions.js @@ -151,6 +151,8 @@ export const urlTestExclusions = [ { url: '/exportwins/rejected/' }, { url: '/exportwins/:winId/edit' }, { url: '/exportwins/:winId/customer-feedback' }, + { url: '/companies/:companyId/export/:exportId/exportwins/create' }, + { url: '/companies/e59a2b0f-7d84-4de7-bc1e-f70339f4255f/overview' }, // Exclude all metadata { url: '/api-proxy/v4/metadata/likelihood-to-land' }, diff --git a/test/functional/cypress/specs/export-win/add-export-win-spec.js b/test/functional/cypress/specs/export-win/add-export-win-spec.js index c73d465a91e..038e612939f 100644 --- a/test/functional/cypress/specs/export-win/add-export-win-spec.js +++ b/test/functional/cypress/specs/export-win/add-export-win-spec.js @@ -31,12 +31,12 @@ const year = twelveMonthsAgo.getFullYear() const create = urls.companies.exportWins.create(company.id) -const officerDetailsStep = create + '&step=officer_details' -const creditForThisWinStep = create + '&step=credit_for_this_win' -const customerDetailsStep = create + '&step=customer_details' -const winDetailsStep = create + '&step=win_details' -const supportProvidedStep = create + '&step=support_provided' -const checkBeforeSendingStep = create + '&step=check_before_sending' +const officerDetailsStep = create + '?step=officer_details' +const creditForThisWinStep = create + '?step=credit_for_this_win' +const customerDetailsStep = create + '?step=customer_details' +const winDetailsStep = create + '?step=win_details' +const supportProvidedStep = create + '?step=support_provided' +const checkBeforeSendingStep = create + '?step=check_before_sending' const formFields = { officerDetails: {