Skip to content

Commit

Permalink
Merge pull request #6479 from uktrade/feature/update-export-wins-endp…
Browse files Browse the repository at this point in the history
…oint

Update export wins endpoint to use a hyphen instead of an underscore
  • Loading branch information
paulgain authored Feb 2, 2024
2 parents be6dc8a + 5aa0988 commit c94b061
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ExportWinsTable = ({ exportWins }) => (
<Table.Cell>{currencyGBP(total_expected_export_value)}</Table.Cell>
<NoWrapCell>{formatMediumDate(date)}</NoWrapCell>
<NoWrapCell>
{formatMediumDate(customer_response.created_on)}
{formatMediumDate(customer_response?.created_on)}
</NoWrapCell>
<NoWrapCell>
{/* TODO: Add target to the link once the path is decided */}
Expand Down
8 changes: 5 additions & 3 deletions src/client/modules/ExportWins/Form/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import {
transformExportProjectForForm,
} from './transformers'

const exportWinEndpoint = '/v4/export-win'

export const getExportProject = ({ id }) =>
apiProxyAxios
.get(`/v4/export/${id}`)
.then(({ data }) => transformExportProjectForForm(data))

export const getExportWin = ({ id }) =>
apiProxyAxios
.get(`/v4/export_win/${id}`)
.get(`${exportWinEndpoint}/${id}`)
.then(({ data }) => transformExportWinForForm(data))

export const saveExportWin = ({ exportWinId, payload }) => {
const request = exportWinId ? apiProxyAxios.patch : apiProxyAxios.post
const endpoint = exportWinId
? `/v4/export_win/${exportWinId}`
: '/v4/export_win'
? `${exportWinEndpoint}/${exportWinId}`
: exportWinEndpoint

return request(endpoint, payload)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react'
import { Button } from 'govuk-react'

import { SecondaryButton, CollectionItem } from '../../../components'
import { CollectionItem } from '../../../components'
import { formatMediumDate } from '../../../utils/date'
import { currencyGBP } from '../../../utils/number-utils'
import ExportWinsResource from '../../../components/Resource/ExportWins'

import urls from '../../../../lib/urls'

export default () => (
<ExportWinsResource.Paginated
id="unconfirmed-export-wins"
Expand All @@ -17,7 +19,7 @@ export default () => (
<li key={item.id}>
<CollectionItem
headingText={item.company.name}
headingUrl={`company-url/${item.company.id}`}
headingUrl={`${urls.companies.detail(item.company.id)}`}
metadata={[
{ label: 'Destination', value: item.country.name },
{ label: 'Contact name', value: item.customer_name },
Expand All @@ -33,9 +35,6 @@ export default () => (
<Button as="a" href={`review/${item.id}`}>
Review export win
</Button>
<SecondaryButton as="a" href={`edit/${item.id}`}>
Edit export win
</SecondaryButton>
</div>
}
/>
Expand Down
1 change: 0 additions & 1 deletion src/middleware/api-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const ALLOWLIST = [
'/v3/event/',
'/v4/event/',
'/v4/export-win/',
'/v4/export_win',
'/v4/event/:id',
'/v3/omis/order/:id/assignee',
'/v3/omis/order/:id/subscriber-list',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ describe('Adding an export win', () => {
'have.text',
'Confirm and send to customer'
)
cy.intercept('POST', '/api-proxy/v4/export_win', {
cy.intercept('POST', '/api-proxy/v4/export-win', {
statusCode: 201,
}).as('apiRequest')
cy.get('[data-test="confirm-and-send-to-customer"]').click()
Expand Down

0 comments on commit c94b061

Please sign in to comment.