Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update export wins endpoint to use a hyphen instead of an underscore #6479

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading