Skip to content

Commit

Permalink
feat(dedicated): correct filter
Browse files Browse the repository at this point in the history
  • Loading branch information
soufien mhelhali committed Oct 31, 2024
1 parent 8f6664e commit a6e81d1
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -79,6 +80,7 @@ export default class AgoraIpV4OrderController {
params: {},
selectedService: null,
selectedServiceRegion: null,
region: null,
};
this.loading = {};
this.user = this.$state.params.user;
Expand Down Expand Up @@ -225,6 +227,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
Expand Down Expand Up @@ -271,7 +274,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) {
Expand Down Expand Up @@ -400,6 +415,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;
Expand Down Expand Up @@ -515,7 +533,7 @@ export default class AgoraIpV4OrderController {
(organisations) => {
let registry = null;

switch (REGION) {
switch (serviceRegion) {
case SERVER_REGION.EUROPE:
registry = ORGANISATION_GROUP.RIPE;
break;
Expand All @@ -526,6 +544,7 @@ export default class AgoraIpV4OrderController {
default:
registry = null;
}

this.organisations = registry
? organisations.filter((org) => org.registry === registry)
: organisations;
Expand Down

0 comments on commit a6e81d1

Please sign in to comment.