Skip to content

Commit

Permalink
Merge pull request #6801 from uktrade/bugfix/TET-733-investments
Browse files Browse the repository at this point in the history
Allow for parameters for metadata API calls
  • Loading branch information
DeanElliott96 authored May 23, 2024
2 parents 93f070b + e766a11 commit 8a35821
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/client/components/Form/elements/FieldInput/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ FieldInput.propTypes = {
/**
* Sets initial value of the input
*/
initialValue: PropTypes.string,
initialValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* Toggles wether the element is a filter or not
*/
Expand Down
36 changes: 17 additions & 19 deletions src/client/modules/Investments/Opportunities/tasks.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
import urls from '../../../../lib/urls'
import { idNamesToValueLabels } from '../../../utils'
import { apiProxyAxios } from '../../../components/Task/utils'
import { transformValueForAPI } from '../../../utils/date'
import { getMetadataOptions } from '../../../metadata'

import { transformInvestmentOpportunityDetails } from './transformers'

export const getOpportunityDetails = ({ opportunityId }) =>
apiProxyAxios
.get(`/v4/large-capital-opportunity/${opportunityId}`)
.get(
urls.investments.opportunities.largeCapitalOpportunityDetails(
opportunityId
)
)
.then(({ data }) => transformInvestmentOpportunityDetails(data))

export const getDetailsMetadata = () =>
Promise.all([
apiProxyAxios.get(
'/v4/metadata/large-capital-opportunity/opportunity-value-type'
),
getMetadataOptions(urls.metadata.largeCapitalOpportunityMetadata()),
]).then(([{ data: valueTypes }]) => ({
valueTypes: idNamesToValueLabels(valueTypes),
}))

export const getRequirementsMetadata = () =>
Promise.all([
apiProxyAxios.get(
'v4/metadata/capital-investment/large-capital-investment-type'
getMetadataOptions(
urls.metadata.capitalInvestmentLargeCapitalInvestmentType()
),
apiProxyAxios.get('/v4/metadata/capital-investment/return-rate'),
apiProxyAxios.get('/v4/metadata/capital-investment/time-horizon'),
]).then(
([
{ data: investmentTypes },
{ data: returnRates },
{ data: timeScales },
]) => ({
investmentTypes: idNamesToValueLabels(investmentTypes),
returnRates: idNamesToValueLabels(returnRates),
timeScales: idNamesToValueLabels(timeScales),
})
)
getMetadataOptions(urls.metadata.capitalInvestmentReturnRate()),
getMetadataOptions(urls.metadata.capitalInvestmentTimeHorizon()),
]).then(([investmentTypes, returnRates, timeScales]) => ({
investmentTypes: investmentTypes,
returnRates: returnRates,
timeScales: timeScales,
}))

export function saveOpportunityDetails({ values, opportunityId }) {
return apiProxyAxios
Expand Down
8 changes: 8 additions & 0 deletions src/lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ module.exports = {
'/investments',
'/opportunities/:opportunityId/interactions'
),
largeCapitalOpportunityDetails: url(
'/api-proxy/v4/large-capital-opportunity',
'/:opportunityId'
),
status: url('/investments', '/opportunities/:opportunityId/status'),
create: url('/investments', '/opportunities/create'),
},
Expand Down Expand Up @@ -659,6 +663,10 @@ module.exports = {
'/api-proxy/v4/metadata/capital-investment',
'/asset-class-interest'
),
largeCapitalOpportunityMetadata: url(
'/api-proxy/v4/metadata/large-capital-opportunity',
'/opportunity-value-type'
),
oneListTier: url('/api-proxy/v4/metadata', '/one-list-tier'),
tradeAgreement: url('/api-proxy/v4/metadata', '/trade-agreement'),
},
Expand Down
4 changes: 4 additions & 0 deletions test/a11y/cypress/config/urlTestExclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ export const urlTestExclusions = [
{ url: '/api-proxy/v4/metadata/capital-investment/equity-percentage' },
{ url: '/api-proxy/v4/metadata/capital-investment/desired-deal-role' },
{ url: '/api-proxy/v4/metadata/capital-investment/asset-class-interest' },
{ url: '/api-proxy/v4/large-capital-opportunity/:opportunityId' },
{
url: '/api-proxy/v4/metadata/large-capital-opportunity/opportunity-value-type',
},
{ url: '/api-proxy/v4/metadata/one-list-tier' },
{ url: '/api-proxy/v4/metadata/trade-agreement' },
]

0 comments on commit 8a35821

Please sign in to comment.