Skip to content

Commit

Permalink
Merge pull request #6588 from uktrade/feature/TET-644-export-potentia…
Browse files Browse the repository at this point in the history
…l-date

Add export potential mapping along with the last updated field
  • Loading branch information
PippoRaimondiDIT authored Mar 8, 2024
2 parents 2b1632b + 4e3a9fe commit deb1ff7
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 15 deletions.
13 changes: 11 additions & 2 deletions src/client/modules/Companies/CompanyExports/ExportsEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import {
ExportExperienceCategoriesResource,
} from '../../../components/Resource'
import { transformArrayIdNameToValueLabel } from '../../../transformers'
import {
buildExportPotential,
buildExportPotentialLastModified,
} from './transformers'
import { exportDetailsLabels } from './labels'
import { buildCompanyBreadcrumbs } from '../utils'

Expand Down Expand Up @@ -77,9 +81,14 @@ const ExportsEdit = () => {
}}
/>
</StyledDd>

<StyledDt>{exportDetailsLabels.exportPotential}</StyledDt>
<StyledDd>Unavailable</StyledDd>
<StyledDd>{buildExportPotential(company)}</StyledDd>
<StyledDt>
{exportDetailsLabels.lastModifiedPotential}
</StyledDt>
<StyledDd>
{buildExportPotentialLastModified(company)}
</StyledDd>
</dl>
<FieldInput
type="hidden"
Expand Down
14 changes: 12 additions & 2 deletions src/client/modules/Companies/CompanyExports/ExportsIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import GreatProfile from './GreatProfile'
import { CompanyResource } from '../../../components/Resource'
import CompanyLayout from '../../../components/Layout/CompanyLayout'
import { exportDetailsLabels, exportPotentialLabels } from './labels'
import { transformExportCountries } from './transformers'
import {
buildExportPotential,
buildExportPotentialLastModified,
transformExportCountries,
} from './transformers'
import DefaultLayoutBase from '../../../components/Layout/DefaultLayoutBase'

const StyledSummaryTable = styled(SummaryTable)`
Expand Down Expand Up @@ -68,7 +72,13 @@ const ExportsIndex = () => {
heading={exportDetailsLabels.exportPotential}
key={exportDetailsLabels.exportPotential}
>
Unavailable
{buildExportPotential(company)}
</SummaryTable.Row>
<SummaryTable.Row
heading={exportDetailsLabels.lastModifiedPotential}
key={exportDetailsLabels.lastModifiedPotential}
>
{buildExportPotentialLastModified(company)}
</SummaryTable.Row>
</SummaryTable>

Expand Down
1 change: 1 addition & 0 deletions src/client/modules/Companies/CompanyExports/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const exportDetailsLabels = {
noInterestCountries: 'Countries of no interest',
greatProfile: 'great.gov.uk business profile',
exportPotential: 'Export potential',
lastModifiedPotential: 'Export potential last updated',
}

export const exportPotentialLabels = {
Expand Down
6 changes: 6 additions & 0 deletions src/client/modules/Companies/CompanyExports/transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export const buildExportPotential = (company) => {
: 'No score given'
}

export const buildExportPotentialLastModified = (company) => {
return company.lastModifiedPotential
? new Date(company.lastModifiedPotential).toISOString().split('T')[0]
: 'No score given'
}

export const transformCountriesForTypeahead = (exportCountries) => {
const groupedExportCountries = groupExportCountries(exportCountries)
return [
Expand Down
21 changes: 14 additions & 7 deletions test/end-to-end/cypress/specs/DIT/companies-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ describe('Export', () => {
assertTable([
'Export growth',
'No profile',
'Unavailable',
'No score given',
'No score given',
'None',
'None',
'None',
Expand All @@ -112,7 +113,8 @@ describe('Export', () => {
assertTable([
'None',
'No profile',
'Unavailable',
'No score given',
'No score given',
'None',
'None',
'None',
Expand Down Expand Up @@ -152,7 +154,8 @@ describe('Export', () => {
assertTable([
'None',
'No profile',
'Unavailable',
'No score given',
'No score given',
'None',
'None',
'None',
Expand All @@ -175,7 +178,8 @@ describe('Export', () => {
assertTable([
'None',
'No profile',
'Unavailable',
'No score given',
'No score given',
'France, Germany',
'None',
'None',
Expand All @@ -191,7 +195,8 @@ describe('Export', () => {
assertTable([
'None',
'No profile',
'Unavailable',
'No score given',
'No score given',
'France, Germany',
'None',
'None',
Expand All @@ -218,7 +223,8 @@ describe('Export', () => {
assertTable([
'None',
'No profile',
'Unavailable',
'No score given',
'No score given',
'Brazil, France, Germany',
'Honduras',
'Chile',
Expand All @@ -245,7 +251,8 @@ describe('Export', () => {
assertTable([
'None',
'No profile',
'Unavailable',
'No score given',
'No score given',
'None',
'None',
'None',
Expand Down
6 changes: 4 additions & 2 deletions test/functional/cypress/specs/companies/export/edit-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ describe('Company Export tab - Edit exports', () => {
label: 'great.gov.uk business profile',
value: 'No profile',
},
{ label: 'Export potential', value: 'Unavailable' },
{ label: 'Export potential', value: 'No score given' },
{ label: 'Export potential last updated', value: 'No score given' },
])
})

Expand Down Expand Up @@ -111,7 +112,8 @@ describe('Company Export tab - Edit exports', () => {
label: 'great.gov.uk business profile',
value: '"Find a supplier" profile (opens in new tab)',
},
{ label: 'Export potential', value: 'Unavailable' },
{ label: 'Export potential', value: 'Medium' },
{ label: 'Export potential last updated', value: '2024-03-07' },
])

cy.contains('"Find a supplier" profile').should(
Expand Down
6 changes: 4 additions & 2 deletions test/functional/cypress/specs/companies/export/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ describe('Company Export tab', () => {
assertExportsTable(fixtures.company.dnbCorp.id, [
{ label: 'Export win category', value: 'None' },
{ label: 'great.gov.uk business profile', value: 'No profile' },
{ label: 'Export potential', value: 'Unavailable' },
{ label: 'Export potential', value: 'No score given' },
{ label: 'Export potential last updated', value: 'No score given' },
])
})

Expand Down Expand Up @@ -261,7 +262,8 @@ describe('Company Export tab', () => {
value: '"Find a supplier" profile (opens in new tab)',
},

{ label: 'Export potential', value: 'Unavailable' },
{ label: 'Export potential', value: 'Medium' },
{ label: 'Export potential last updated', value: '2024-03-07' },
])

cy.contains('"Find a supplier" profile').should(
Expand Down
1 change: 1 addition & 0 deletions test/sandbox/fixtures/v4/company/company-dnb-ltd.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"is_number_of_employees_estimated": true,
"great_profile_status": "published",
"export_potential": "medium",
"last_modified_potential": "2024-03-07",
"export_countries": [
{
"country": {
Expand Down

0 comments on commit deb1ff7

Please sign in to comment.