Skip to content

Commit

Permalink
Add the export win success page
Browse files Browse the repository at this point in the history
After a user has added an export win they will be redirected to
a success page. This page guides them on what will happen next.
  • Loading branch information
paulgain committed Mar 12, 2024
1 parent 892f284 commit f8257a1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/apps/routers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const reactRoutes = [
'/exportwins/sent',
'/exportwins/rejected',
'/exportwins/:winId/details',
'/exportwins/:winId/success',
'/exportwins/:winId/customer-feedback',
'/companies/:companyId/dnb-hierarchy',
'/companies/:companyId/company-tree',
Expand Down
18 changes: 14 additions & 4 deletions src/client/components/LocalHeader/FlashMessages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const FlashMessages = ({
getFlashMessages()
return () => clearFlashMessages()
}, [])
return !isEmpty(flashMessages) ? (
return isEmpty(flashMessages) ? null : (
<UnorderedList listStyleType="none" data-test="flash">
{Object.entries(flashMessages).map(([type, messages]) => {
/*
Expand All @@ -82,20 +82,30 @@ const FlashMessages = ({
<li key={body}>
<StyledStatusMessage colour={messageColours[parts[0]]}>
<StyledHeading>{heading}</StyledHeading>
<StyledBody dangerouslySetInnerHTML={{ __html: body }} />
{typeof body === 'string' ? (
<StyledBody dangerouslySetInnerHTML={{ __html: body }} />
) : (
<StyledBody>{body}</StyledBody>
)}
</StyledStatusMessage>
</li>
))
: messages.map((body, i) => (
<li key={i}>
<StyledStatusMessage colour={messageColours[type]}>
<StyledMessage dangerouslySetInnerHTML={{ __html: body }} />
{typeof body === 'string' ? (
<StyledMessage
dangerouslySetInnerHTML={{ __html: body }}
/>
) : (
<StyledMessage>{body}</StyledMessage>
)}
</StyledStatusMessage>
</li>
))
})}
</UnorderedList>
) : null
)
}

const flashMessagePropTypes = {
Expand Down
4 changes: 3 additions & 1 deletion src/client/modules/ExportWins/Form/ExportWinForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ const ExportWinForm = ({
id="export-win-form"
showStepInUrl={true}
cancelRedirectTo={() => urls.companies.exportWins.sent()}
redirectTo={() => urls.companies.exportWins.sent()}
redirectTo={(result) =>
urls.companies.exportWins.success(result.data.id)
}
analyticsFormName="exportWinForm"
submissionTaskName={TASK_GET_EXPORT_WINS_SAVE_FORM}
initialValuesTaskName={initialValuesTaskName}
Expand Down
55 changes: 55 additions & 0 deletions src/client/modules/ExportWins/Form/Success.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react'
import { H4 } from '@govuk-react/heading'

import ExportWin from '../../../components/Resource/ExportWin'
import { ExportWinsLink, VerticalSpacer } from '../Details'
import { DefaultLayout } from '../../../components'
import urls from '../../../../lib/urls'

const ExportWinSuccess = ({ winId }) => (
<ExportWin.Inline id={winId}>
{(exportWin) =>
exportWin &&
`The export win ${exportWin.nameOfExport} to ${exportWin.country.name} has been` +
` sent to ${exportWin.companyContacts[0].email} for review and confirmation.`
}
</ExportWin.Inline>
)

const Success = ({ match }) => (
<DefaultLayout
pageTitle="Success"
breadcrumbs={[
{
link: urls.dashboard.index(),
text: 'Home',
},
{
link: urls.companies.exportWins.index(),
text: 'Export wins',
},
{
text: 'Success',
},
]}
flashMessages={{
success: [<ExportWinSuccess winId={match.params.winId} />],
}}
>
<H4 data-test="heading" as="h2">
What happens next?
</H4>
<p data-test="review">
The customer will review the export win and have the option to provide
feedback.
</p>
<p data-test="email">
You will be sent an email once the customer has responded.
</p>
<VerticalSpacer>
<ExportWinsLink />
</VerticalSpacer>
</DefaultLayout>
)

export default Success
6 changes: 6 additions & 0 deletions src/client/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ExportWinsTabNav from './modules/ExportWins/Status/ExportWinsTabNav'
import { CreateExportWin, EditExportWin } from './modules/ExportWins/Form'
import ExportWinsRedirect from './modules/ExportWins/Status/Redirect'
import ExportWinDetails from './modules/ExportWins/Details'
import Success from './modules/ExportWins/Form/Success'
import CompanyHierarchy from './modules/Companies/CompanyHierarchy'
import CompanyTree from './modules/Companies/CompanyHierarchy/CompanyTree'
import Community from './modules/Community'
Expand Down Expand Up @@ -507,6 +508,11 @@ const routes = {
module: 'datahub:companies',
component: CreateExportWin,
},
{
path: '/exportwins/:winId/success',
module: 'datahub:companies',
component: Success,
},
{
path: '/exportwins/:winId/edit',
module: 'datahub:companies',
Expand Down
1 change: 1 addition & 0 deletions src/lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ module.exports = {
'/companies',
'/:companyId/export/:exportId/exportwins/create'
),
success: url('/exportwins', '/:winId/success'),
customerFeedback: url('/exportwins', '/:winId/customer-feedback'),
},
overview: {
Expand Down
1 change: 1 addition & 0 deletions test/a11y/cypress/config/urlTestExclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const urlTestExclusions = [
{ url: '/exportwins/sent/' },
{ url: '/exportwins/rejected/' },
{ url: '/exportwins/:winId/edit' },
{ url: '/exportwins/:winId/thankyou' },
{ url: '/exportwins/:winId/customer-feedback' },
{ url: '/companies/:companyId/export/:exportId/exportwins/create' },

Expand Down

0 comments on commit f8257a1

Please sign in to comment.