Skip to content

Commit

Permalink
Add export wins rejected tab (#6550)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgain authored and swenban committed Feb 27, 2024
1 parent 3424365 commit 91f0cef
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 82 deletions.
1 change: 1 addition & 0 deletions src/apps/routers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 14 additions & 1 deletion src/client/components/CollectionList/CollectionItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const CollectionItem = ({
titleRenderer = null,
useReactRouter = false,
buttons,
buttonRenderer,
footerRenderer,
footerdata,
}) => (
Expand Down Expand Up @@ -129,7 +130,18 @@ const CollectionItem = ({
) : (
<Metadata rows={metadata} />
)}
{buttons && <StyledButtonWrapper>{buttons}</StyledButtonWrapper>}
{/*
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 ? (
<StyledButtonWrapper>{buttons}</StyledButtonWrapper>
) : buttonRenderer ? (
buttonRenderer()
) : null}

{footerRenderer && (
<StyledFooterWrapper>{footerRenderer(footerdata)} </StyledFooterWrapper>
)}
Expand Down Expand Up @@ -161,6 +173,7 @@ CollectionItem.propTypes = {
type: PropTypes.string,
metadataRenderer: PropTypes.func,
titleRenderer: PropTypes.func,
buttonRenderer: PropTypes.func,
footerRenderer: PropTypes.func,
}

Expand Down
11 changes: 0 additions & 11 deletions src/client/modules/ExportWins/Redirect.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 (
<DefaultLayout
Expand All @@ -25,6 +26,10 @@ const ExportWins = ({ location }) => {
label="Export wins tab nav"
routed={true}
tabs={{
[urls.companies.exportWins.rejected()]: {
label: 'Rejected',
content: <WinsRejectedList />,
},
[urls.companies.exportWins.sent()]: {
label: 'Sent',
content: <WinsSentList />,
Expand All @@ -39,4 +44,4 @@ const ExportWins = ({ location }) => {
)
}

export default ExportWins
export default ExportWinsTabNav
11 changes: 11 additions & 0 deletions src/client/modules/ExportWins/Status/Redirect.jsx
Original file line number Diff line number Diff line change
@@ -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 = () => (
<Redirect to={urls.companies.exportWins.rejected()} />
)

export default ExportsWinsRedirect
63 changes: 63 additions & 0 deletions src/client/modules/ExportWins/Status/WinsRejectedList.jsx
Original file line number Diff line number Diff line change
@@ -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 () => (
<ExportWinsResource.Paginated
id="export-wins-rejected"
payload={{ confirmed: WIN_FILTERS.REJECTED }}
>
{(page) => (
<ul>
{page.map((item) => (
<li key={item.id}>
<CollectionItem
headingText={item.company.name}
headingUrl={urls.companies.overview.index(item.company.id)}
metadata={[
{ label: 'Destination:', value: item.country.name },
{
label: 'Contact name:',
// TODO: This needs to be a link, the MetadataItem
// needs to take a JSX element as a paramter.
value: item.company_contacts[0].name,
},
{
label: 'Total value:',
value: currencyGBP(item.total_expected_export_value),
},
{ label: 'Date won:', value: formatMediumDate(item.date) },
{
label: 'Date modified:',
value: formatMediumDate(item.modified_on),
},
]}
buttonRenderer={() => (
<ButtonContainer>
<Button
as={ReactRouterLink}
to={urls.companies.exportWins.details(item.id)}
>
Review export win
</Button>
</ButtonContainer>
)}
/>
</li>
))}
</ul>
)}
</ExportWinsResource.Paginated>
)
58 changes: 58 additions & 0 deletions src/client/modules/ExportWins/Status/WinsSentList.jsx
Original file line number Diff line number Diff line change
@@ -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 () => (
<ExportWinsResource.Paginated
id="export-wins-sent"
payload={{ confirmed: WIN_FILTERS.SENT }}
>
{(page) => (
<ul>
{page.map((item) => (
<li key={item.id}>
<CollectionItem
headingText={item.company.name}
headingUrl={urls.companies.overview.index(item.company.id)}
metadata={[
{ label: 'Destination: ', value: item.country.name },
{
label: 'Contact name:',
// TODO: This needs to be a link, the MetadataItem
// needs to take a JSX element
value: item.company_contacts[0].name,
},
{
label: 'Total value: ',
value: currencyGBP(item.total_expected_export_value),
},
{ label: 'Date won: ', value: formatMediumDate(item.date) },
{ label: 'First sent: ', value: '???' },
{ label: 'Last sent: ', value: '???' },
]}
buttonRenderer={() => (
<ButtonContainer>
<Button as={ReactRouterLink} onClick={() => alert('TODO')}>
Resend export win
</Button>
</ButtonContainer>
)}
/>
</li>
))}
</ul>
)}
</ExportWinsResource.Paginated>
)
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
File renamed without changes.
48 changes: 0 additions & 48 deletions src/client/modules/ExportWins/WinsSentList.jsx

This file was deleted.

13 changes: 9 additions & 4 deletions src/client/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion test/a11y/cypress/config/urlTestExclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const urlTestExclusions = [
{ url: '/companies/:companyId/edit-history' },
{ url: '/companies/:companyId/exports' },
{ url: '/exportwins/' },
{ url: '/exportwins/sent/' },
{ url: '/companies/:companyId/investments/large-capital-profile' },
{ url: '/companies/:companyId/account-management' },
{ url: '/company-lists/' },
Expand Down Expand Up @@ -143,6 +142,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' },
Expand Down
Loading

0 comments on commit 91f0cef

Please sign in to comment.