From 21b889a56d954b517d45c07e56a34a8aff455341 Mon Sep 17 00:00:00 2001 From: soufien mhelhali Date: Thu, 31 Oct 2024 06:00:12 +0100 Subject: [PATCH] feat(dedicated): correct filter --- .../ip/agoraOrder/ipv4/ipv4.controller.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js b/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js index 973196b7e3c9..a0e6ddf86ae8 100644 --- a/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js +++ b/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js @@ -6,6 +6,7 @@ import get from 'lodash/get'; import head from 'lodash/head'; import intersection from 'lodash/intersection'; import last from 'lodash/last'; +import first from 'lodash/first'; import map from 'lodash/map'; import range from 'lodash/range'; import uniq from 'lodash/uniq'; @@ -81,6 +82,7 @@ export default class AgoraIpV4OrderController { params: {}, selectedService: null, selectedServiceRegion: null, + region: null, }; this.loading = {}; this.user = this.$state.params.user; @@ -232,6 +234,7 @@ export default class AgoraIpV4OrderController { request.then((region) => { if (region) { + this.model.region = region; this.model.selectedServiceRegion = this.model.selectedService?.type === PRODUCT_TYPES.dedicatedServer.typeName @@ -278,7 +281,19 @@ export default class AgoraIpV4OrderController { }); return ipOffer.details.product.configurations.find( (config) => config.name === 'country', - )?.values; + )?.values; + } + + static getRegionFromServiceRegion(region) { + const serviceExt = first(region.split('-')); + if (serviceExt === 'eu') { + return SERVER_REGION.EUROPE; + } + if (serviceExt === 'ca') { + return SERVER_REGION.CANADA; + } + + return SERVER_REGION.USA; } loadPrivateCloudIpOffers(serviceName) { @@ -475,6 +490,9 @@ export default class AgoraIpV4OrderController { const REGION = AgoraIpV4OrderController.getRegionFromServiceName( this.model.selectedService.serviceName, ); + const serviceRegion = + this.model.region && + AgoraIpV4OrderController.getRegionFromServiceRegion(this.model.region); this.isPrivateCloudOffer = this.model?.selectedService?.type === PRODUCT_TYPES.privateCloud.typeName; @@ -589,7 +607,7 @@ export default class AgoraIpV4OrderController { (organisations) => { let registry = null; - switch (REGION) { + switch (serviceRegion) { case SERVER_REGION.EUROPE: registry = ORGANISATION_GROUP.RIPE; break; @@ -600,6 +618,7 @@ export default class AgoraIpV4OrderController { default: registry = null; } + this.organisations = registry ? organisations.filter((org) => org.registry === registry) : organisations;