Skip to content

Commit

Permalink
DPM 616 filters on investment profiles (#6759)
Browse files Browse the repository at this point in the history
* Use urls.metadata for investment profile filter options.
* Exclude end point from a11y check
  • Loading branch information
marijnkampf authored and cgsunkel committed May 17, 2024
1 parent bfec888 commit 3d2553a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 52 deletions.
94 changes: 43 additions & 51 deletions src/client/modules/Investments/Profiles/tasks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import urls from '../../../../lib/urls'
import { apiProxyAxios } from '../../../components/Task/utils'
import { getMetadataOptions } from '../../../metadata'

import transformLargeCapitalProfiles from './transformers'

Expand Down Expand Up @@ -67,63 +69,53 @@ export function getLargeCapitalProfiles({
}))
}

const idName2valueLabel = ({ id, name }) => ({ value: id, label: name })

const mapOptionsWithCategory = (options, category) =>
options.map((option) =>
Object.assign(idName2valueLabel(option), { categoryLabel: category })
)

export const loadFilterOptions = () =>
Promise.all([
apiProxyAxios.get('/v4/metadata/country'),
apiProxyAxios.get('/v4/metadata/capital-investment/asset-class-interest'),
apiProxyAxios.get('/v4/metadata/capital-investment/investor-type'),
apiProxyAxios.get(
'/v4/metadata/capital-investment/required-checks-conducted'
getMetadataOptions(urls.metadata.country()),
getMetadataOptions(urls.metadata.capitalInvestmentAssetClassInterest()),
getMetadataOptions(urls.metadata.capitalInvestmentInvestorType()),
getMetadataOptions(
urls.metadata.capitalInvestmentRequiredChecksConducted()
),
apiProxyAxios.get('/v4/metadata/capital-investment/deal-ticket-size'),
apiProxyAxios.get(
'v4/metadata/capital-investment/large-capital-investment-type'
getMetadataOptions(urls.metadata.capitalInvestmentDealTicketSize()),
getMetadataOptions(
urls.metadata.capitalInvestmentLargeCapitalInvestmentType()
),
apiProxyAxios.get('/v4/metadata/capital-investment/return-rate'),
apiProxyAxios.get('/v4/metadata/capital-investment/time-horizon'),
apiProxyAxios.get('/v4/metadata/capital-investment/restriction'),
apiProxyAxios.get('/v4/metadata/capital-investment/construction-risk'),
apiProxyAxios.get('/v4/metadata/capital-investment/equity-percentage'),
apiProxyAxios.get('/v4/metadata/capital-investment/desired-deal-role'),
apiProxyAxios.get('/v4/metadata/uk-region'),
getMetadataOptions(urls.metadata.capitalInvestmentReturnRate()),
getMetadataOptions(urls.metadata.capitalInvestmentTimeHorizon()),
getMetadataOptions(urls.metadata.capitalInvestmentRestriction()),
getMetadataOptions(urls.metadata.capitalInvestmentConstructionRisk()),
getMetadataOptions(urls.metadata.capitalInvestmentEquityPercentage()),
getMetadataOptions(urls.metadata.capitalInvestmentDesiredDealRole()),
getMetadataOptions(urls.metadata.ukRegion(), { filterDisabled: false }),
]).then(
([
{ data: countries },
{ data: classes },
{ data: investorTypes },
{ data: requiredChecksConducted },
{ data: ticketSizes },
{ data: investmentTypes },
{ data: returnRates },
{ data: timeHorizons },
{ data: restrictions },
{ data: constructionRisks },
{ data: equityPercentages },
{ data: dealRoles },
{ data: ukRegionsOfInterest },
countries,
assetClassesOfInterest,
investorTypes,
requiredChecksConducted,
dealTicketSize,
investmentTypes,
minimumReturnRate,
timeHorizon,
restrictions,
constructionRisk,
minimumEquityPercentage,
desiredDealRole,
ukRegionsOfInterest,
]) => ({
countries: countries.map(idName2valueLabel),
assetClassesOfInterest: classes.map(idName2valueLabel),
investorTypes: investorTypes.map(idName2valueLabel),
requiredChecksConducted: requiredChecksConducted.map(idName2valueLabel),
dealTicketSize: ticketSizes.map(idName2valueLabel),
investmentTypes: investmentTypes.map(idName2valueLabel),
minimumReturnRate: mapOptionsWithCategory(returnRates, 'Min Return Rate'),
timeHorizon: timeHorizons.map(idName2valueLabel),
restrictions: restrictions.map(idName2valueLabel),
constructionRisk: constructionRisks.map(idName2valueLabel),
minimumEquityPercentage: mapOptionsWithCategory(
equityPercentages,
'Min Equity %'
),
desiredDealRole: dealRoles.map(idName2valueLabel),
ukRegionsOfInterest: ukRegionsOfInterest.map(idName2valueLabel),
countries,
assetClassesOfInterest,
investorTypes,
requiredChecksConducted,
dealTicketSize,
investmentTypes,
minimumReturnRate,
timeHorizon,
restrictions,
constructionRisk,
minimumEquityPercentage,
desiredDealRole,
ukRegionsOfInterest,
})
)
4 changes: 4 additions & 0 deletions src/lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ module.exports = {
'/api-proxy/v4/metadata/capital-investment',
'/large-capital-investment'
),
capitalInvestmentLargeCapitalInvestmentType: url(
'/api-proxy/v4/metadata/capital-investment',
'/large-capital-investment-type'
),
capitalInvestmentReturnRate: url(
'/api-proxy/v4/metadata/capital-investment',
'/return-rate'
Expand Down
3 changes: 3 additions & 0 deletions test/a11y/cypress/config/urlTestExclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ export const urlTestExclusions = [
{
url: '/api-proxy/v4/metadata/capital-investment/large-capital-investment',
},
{
url: '/api-proxy/v4/metadata/capital-investment/large-capital-investment-type',
},
{ url: '/api-proxy/v4/metadata/capital-investment/return-rate' },
{ url: '/api-proxy/v4/metadata/capital-investment/time-horizon' },
{ url: '/api-proxy/v4/metadata/capital-investment/restriction' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ describe('Investor profiles filters', () => {
...ukRegionListFaker(2),
...ukRegionListFaker(2, { disabled_on: '2018-01-01' }),
]
cy.intercept('GET', urls.metadata.ukRegion(), ukRegions).as(
cy.intercept('GET', `${urls.metadata.ukRegion()}*`, ukRegions).as(
'ukRegionsApiRequest'
)
cy.visit(urls.investments.profiles.index())
Expand Down

0 comments on commit 3d2553a

Please sign in to comment.