diff --git a/src/apps/routers.js b/src/apps/routers.js index dd8db19c373..507eeda9bc5 100644 --- a/src/apps/routers.js +++ b/src/apps/routers.js @@ -30,6 +30,7 @@ const reactRoutes = [ '/exportwins/:winId/edit', '/exportwins/won', '/exportwins/sent', + '/exportwins/rejected', '/exportwins/:winId/details', '/companies/:companyId/dnb-hierarchy', '/companies/:companyId/company-tree', diff --git a/src/client/components/CollectionList/CollectionItem.jsx b/src/client/components/CollectionList/CollectionItem.jsx index f36962ed914..0bb8028ca5a 100644 --- a/src/client/components/CollectionList/CollectionItem.jsx +++ b/src/client/components/CollectionList/CollectionItem.jsx @@ -75,6 +75,7 @@ const CollectionItem = ({ titleRenderer = null, useReactRouter = false, buttons, + buttonRenderer, footerRenderer, footerdata, }) => ( @@ -129,7 +130,18 @@ const CollectionItem = ({ ) : ( )} - {buttons && {buttons}} + {/* + TODO: Tech-debt, this needs to be refactored so we have a consistent + way of rendering buttons, ideally we should use the buttonRenderer + prop as a function that returns a JSX element and do away with the + buttons prop altogether as it's completely inflexible. + */} + {buttons ? ( + {buttons} + ) : buttonRenderer ? ( + buttonRenderer() + ) : null} + {footerRenderer && ( {footerRenderer(footerdata)} )} @@ -161,6 +173,7 @@ CollectionItem.propTypes = { type: PropTypes.string, metadataRenderer: PropTypes.func, titleRenderer: PropTypes.func, + buttonRenderer: PropTypes.func, footerRenderer: PropTypes.func, } diff --git a/src/client/modules/ExportWins/Redirect.jsx b/src/client/modules/ExportWins/Redirect.jsx deleted file mode 100644 index 8cea5464abd..00000000000 --- a/src/client/modules/ExportWins/Redirect.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react' -import { Redirect } from 'react-router-dom' - -import urls from '../../../lib/urls' - -// Redirect from /exportwins to /exportwins/sent -const ExportsWinsRedirect = () => ( - -) - -export default ExportsWinsRedirect diff --git a/src/client/modules/ExportWins/index.jsx b/src/client/modules/ExportWins/Status/ExportWinsTabNav.jsx similarity index 68% rename from src/client/modules/ExportWins/index.jsx rename to src/client/modules/ExportWins/Status/ExportWinsTabNav.jsx index a884d890697..18484d5f852 100644 --- a/src/client/modules/ExportWins/index.jsx +++ b/src/client/modules/ExportWins/Status/ExportWinsTabNav.jsx @@ -1,15 +1,16 @@ import React from 'react' import { capitalize } from 'lodash' -import { DefaultLayout } from '../../components' -import TabNav from '../../components/TabNav' +import { DefaultLayout } from '../../../components' +import TabNav from '../../../components/TabNav' +import WinsRejectedList from './WinsRejectedList' import WinsSentList from './WinsSentList' import WinsWonTable from './WinsWonTable' -import urls from '../../../lib/urls' +import urls from '../../../../lib/urls' const TITLE = /([^\/]+$)/ -const ExportWins = ({ location }) => { +const ExportWinsTabNav = ({ location }) => { const title = TITLE.exec(location.pathname)[0] return ( { label="Export wins tab nav" routed={true} tabs={{ + [urls.companies.exportWins.rejected()]: { + label: 'Rejected', + content: , + }, [urls.companies.exportWins.sent()]: { label: 'Sent', content: , @@ -39,4 +44,4 @@ const ExportWins = ({ location }) => { ) } -export default ExportWins +export default ExportWinsTabNav diff --git a/src/client/modules/ExportWins/Status/Redirect.jsx b/src/client/modules/ExportWins/Status/Redirect.jsx new file mode 100644 index 00000000000..a0dc49c1e02 --- /dev/null +++ b/src/client/modules/ExportWins/Status/Redirect.jsx @@ -0,0 +1,11 @@ +import React from 'react' +import { Redirect } from 'react-router-dom' + +import urls from '../../../../lib/urls' + +// Redirect from /exportwins to /exportwins/rejected +const ExportsWinsRedirect = () => ( + +) + +export default ExportsWinsRedirect diff --git a/src/client/modules/ExportWins/Status/WinsRejectedList.jsx b/src/client/modules/ExportWins/Status/WinsRejectedList.jsx new file mode 100644 index 00000000000..7324b30b5c4 --- /dev/null +++ b/src/client/modules/ExportWins/Status/WinsRejectedList.jsx @@ -0,0 +1,63 @@ +import React from 'react' +import { Link as ReactRouterLink } from 'react-router-dom' +import { Button } from 'govuk-react' +import styled from 'styled-components' + +import ExportWinsResource from '../../../components/Resource/ExportWins' +import { currencyGBP } from '../../../utils/number-utils' +import { formatMediumDate } from '../../../utils/date' +import { CollectionItem } from '../../../components' +import { WIN_FILTERS } from './constants' +import urls from '../../../../lib/urls' + +const ButtonContainer = styled('div')({ + marginTop: 10, +}) + +export default () => ( + + {(page) => ( +
    + {page.map((item) => ( +
  • + ( + + + + )} + /> +
  • + ))} +
+ )} +
+) diff --git a/src/client/modules/ExportWins/Status/WinsSentList.jsx b/src/client/modules/ExportWins/Status/WinsSentList.jsx new file mode 100644 index 00000000000..d88e1b7b8fe --- /dev/null +++ b/src/client/modules/ExportWins/Status/WinsSentList.jsx @@ -0,0 +1,58 @@ +import React from 'react' +import { Link as ReactRouterLink } from 'react-router-dom' +import { Button } from 'govuk-react' +import styled from 'styled-components' + +import ExportWinsResource from '../../../components/Resource/ExportWins' +import { currencyGBP } from '../../../utils/number-utils' +import { formatMediumDate } from '../../../utils/date' +import { CollectionItem } from '../../../components' +import { WIN_FILTERS } from './constants' +import urls from '../../../../lib/urls' + +const ButtonContainer = styled('div')({ + marginTop: 10, +}) + +export default () => ( + + {(page) => ( +
    + {page.map((item) => ( +
  • + ( + + + + )} + /> +
  • + ))} +
+ )} +
+) diff --git a/src/client/modules/ExportWins/WinsWonTable.jsx b/src/client/modules/ExportWins/Status/WinsWonTable.jsx similarity index 89% rename from src/client/modules/ExportWins/WinsWonTable.jsx rename to src/client/modules/ExportWins/Status/WinsWonTable.jsx index 16b46373ecd..d01a96994c4 100644 --- a/src/client/modules/ExportWins/WinsWonTable.jsx +++ b/src/client/modules/ExportWins/Status/WinsWonTable.jsx @@ -3,11 +3,11 @@ import { Link as ReactRouterLink } from 'react-router-dom' import { Table, Link } from 'govuk-react' import styled from 'styled-components' -import ExportWinsResource from '../../components/Resource/ExportWins' -import { currencyGBP } from '../../utils/number-utils' -import { formatMediumDate } from '../../utils/date' +import ExportWinsResource from '../../../components/Resource/ExportWins' +import { currencyGBP } from '../../../utils/number-utils' +import { formatMediumDate } from '../../../utils/date' import { WIN_FILTERS } from './constants' -import urls from '../../../lib/urls' +import urls from '../../../../lib/urls' const NoWrapCell = styled(Table.Cell)` white-space: nowrap; diff --git a/src/client/modules/ExportWins/constants.js b/src/client/modules/ExportWins/Status/constants.js similarity index 100% rename from src/client/modules/ExportWins/constants.js rename to src/client/modules/ExportWins/Status/constants.js diff --git a/src/client/modules/ExportWins/WinsSentList.jsx b/src/client/modules/ExportWins/WinsSentList.jsx deleted file mode 100644 index a5a2630d442..00000000000 --- a/src/client/modules/ExportWins/WinsSentList.jsx +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react' -import { Link as ReactRouterLink } from 'react-router-dom' -import { Button } from 'govuk-react' - -import ExportWinsResource from '../../components/Resource/ExportWins' -import { currencyGBP } from '../../utils/number-utils' -import { formatMediumDate } from '../../utils/date' -import { CollectionItem } from '../../components' -import { WIN_FILTERS } from './constants' -import urls from '../../../lib/urls' - -export default () => ( - - {(page) => ( -
    - {page.map((item) => ( -
  • - - Review export win - - } - /> -
  • - ))} -
- )} -
-) diff --git a/src/client/routes.js b/src/client/routes.js index fc1fce9e966..e41a412a072 100644 --- a/src/client/routes.js +++ b/src/client/routes.js @@ -16,9 +16,9 @@ import { } from './modules/ExportPipeline/ExportForm' import ExportFormDelete from './modules/ExportPipeline/ExportDelete' import ExportDetails from './modules/ExportPipeline/ExportDetails' -import ExportWins from './modules/ExportWins/' +import ExportWinsTabNav from './modules/ExportWins/Status/ExportWinsTabNav' import { CreateExportWin, EditExportWin } from './modules/ExportWins/Form' -import ExportWinsRedirect from './modules/ExportWins/Redirect' +import ExportWinsRedirect from './modules/ExportWins/Status/Redirect' import ExportWinDetails from './modules/ExportWins/Details' import CompanyHierarchy from './modules/Companies/CompanyHierarchy' import CompanyTree from './modules/Companies/CompanyHierarchy/CompanyTree' @@ -464,15 +464,20 @@ const routes = { }, ], exportWins: [ + { + path: '/exportwins/rejected', + module: 'datahub:companies', + component: ExportWinsTabNav, + }, { path: '/exportwins/sent', module: 'datahub:companies', - component: ExportWins, + component: ExportWinsTabNav, }, { path: '/exportwins/won', module: 'datahub:companies', - component: ExportWins, + component: ExportWinsTabNav, }, { path: '/exportwins', diff --git a/src/lib/urls.js b/src/lib/urls.js index 30e72b399d9..aee9c57c254 100644 --- a/src/lib/urls.js +++ b/src/lib/urls.js @@ -222,8 +222,9 @@ module.exports = { index: url('/exportwins'), create: url('/exportwins/create'), details: url('/exportwins', '/:winId/details'), - won: url('/exportwins/won'), + rejected: url('/exportwins/rejected'), sent: url('/exportwins/sent'), + won: url('/exportwins/won'), }, overview: { index: url('/companies', '/:companyId/overview'), diff --git a/test/a11y/cypress/config/urlTestExclusions.js b/test/a11y/cypress/config/urlTestExclusions.js index e34029f3918..e80eaa0ae72 100644 --- a/test/a11y/cypress/config/urlTestExclusions.js +++ b/test/a11y/cypress/config/urlTestExclusions.js @@ -8,6 +8,7 @@ export const urlTestExclusions = [ { url: '/companies/:companyId/exports' }, { url: '/exportwins/' }, { url: '/exportwins/sent/' }, + { url: '/exportwins/rejected/' }, { url: '/companies/:companyId/investments/large-capital-profile' }, { url: '/companies/:companyId/account-management' }, { url: '/company-lists/' }, @@ -143,6 +144,7 @@ export const urlTestExclusions = [ { url: '/oauth/sign-out/' }, { url: '/exportwins/1/details' }, { url: '/exportwins/sent/' }, + { url: '/exportwins/rejected/' }, { url: '/companies/e59a2b0f-7d84-4de7-bc1e-f70339f4255f/overview' }, // Exclude all metadata { url: '/api-proxy/v4/metadata/likelihood-to-land' }, diff --git a/test/component/cypress/specs/ExportWins/TabNav.cy.jsx b/test/component/cypress/specs/ExportWins/TabNav.cy.jsx index 972c554c35a..53a21c85639 100644 --- a/test/component/cypress/specs/ExportWins/TabNav.cy.jsx +++ b/test/component/cypress/specs/ExportWins/TabNav.cy.jsx @@ -2,16 +2,16 @@ import React from 'react' import { assertBreadcrumbs } from '../../../../functional/cypress/support/assertions' import { assertLocalNav } from '../../../../end-to-end/cypress/support/assertions' -import ExportWins from '../../../../../src/client/modules/ExportWins' +import ExportWinsTabNav from '../../../../../src/client/modules/ExportWins/Status/ExportWinsTabNav' import urls from '../../../../../src/lib/urls' import DataHubProvider from '../provider' describe('Export wins tab navigation', () => { const Component = (props) => ( - @@ -19,8 +19,21 @@ describe('Export wins tab navigation', () => { ) context('when rendering the breadcrumbs', () => { - it('should render both Home and Sent', () => { + it('should render both Home and Rejected', () => { cy.mount() + assertBreadcrumbs({ + Home: urls.dashboard.index(), + Rejected: null, + }) + }) + it('should render both Home and Sent', () => { + cy.mount( + + ) assertBreadcrumbs({ Home: urls.dashboard.index(), Sent: null, @@ -49,11 +62,11 @@ describe('Export wins tab navigation', () => { }) context('When rendering the TabNav component', () => { - it('should display both Sent and Won tabs', () => { + it('should render three tabs: Rejected, Sent and Won', () => { cy.mount() cy.get('[data-test="tablist"]').should('exist') cy.get('[data-test="tab-item"]').as('tabItems') - assertLocalNav('@tabItems', ['Sent', 'Won']) + assertLocalNav('@tabItems', ['Rejected', 'Sent', 'Won']) }) }) }) diff --git a/test/component/cypress/specs/ExportWins/Table.cy.jsx b/test/component/cypress/specs/ExportWins/Table.cy.jsx index 2f150aab607..be26b37d7d3 100644 --- a/test/component/cypress/specs/ExportWins/Table.cy.jsx +++ b/test/component/cypress/specs/ExportWins/Table.cy.jsx @@ -1,7 +1,7 @@ import React from 'react' import DataHubProvider from '../provider' -import { WinsWonTable } from '../../../../../src/client/modules/ExportWins/WinsWonTable' +import { WinsWonTable } from '../../../../../src/client/modules/ExportWins/Status/WinsWonTable' import { exportWinsFaker } from '../../../../functional/cypress/fakers/export-wins' import { currencyGBP } from '../../../../../src/client/utils/number-utils' import { formatMediumDate } from '../../../../../src/client/utils/date' diff --git a/test/sandbox/routes/v4/export-win/export-win.js b/test/sandbox/routes/v4/export-win/export-win.js index 48e58e1a1f5..20e8a5dd391 100644 --- a/test/sandbox/routes/v4/export-win/export-win.js +++ b/test/sandbox/routes/v4/export-win/export-win.js @@ -14,6 +14,13 @@ const fakeExportWin = (_, i) => ({ id: faker.string.uuid(), name: faker.location.country(), }, + company_contacts: [ + { + id: faker.string.uuid(), + name: faker.company.name(), + email: faker.internet.email(), + }, + ], customer_name: faker.person.fullName(), customer_job_title: faker.person.jobTitle(), customer_email_address: faker.internet.email(),