Skip to content

Commit 89f533e

Browse files
marie-jantleblanc
authored andcommitted
fix(pci.projects.instance): display currency according to sub not locale (#783)
ref: MANAGER-2737
1 parent 0fe0441 commit 89f533e

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
export default class FlavorBillingController {
2+
/* @ngInject */
3+
constructor(TranslateService) {
4+
this.TranslateService = TranslateService;
5+
}
6+
27
$onInit() {
38
this.monthly = this.monthlyBilling === true;
49
this.number = this.number || 1;
510

611
this.disabled = this.disabled || false;
712
}
813

14+
set flavor(flavor) {
15+
if (flavor) {
16+
this.prices = flavor.prices;
17+
this.PriceFormatter = new Intl.NumberFormat(this.TranslateService.getUserLocale().replace('_', '-'), { style: 'currency', currency: flavor.prices.hourly.currencyCode });
18+
}
19+
}
20+
921
selectBilling(monthlyBilling) {
1022
this.monthlyBilling = monthlyBilling;
1123
}
1224

1325
getPrice(price) {
1426
return this.number * price.value;
1527
}
28+
29+
formatPrice(price) {
30+
return this.PriceFormatter.format(this.getPrice(price));
31+
}
1632
}

packages/manager/modules/pci/src/components/project/flavor-billing/flavor-billing.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
data-variant="light"
99
data-on-change="$ctrl.selectBilling(modelValue)"
1010
data-disabled="$ctrl.disabled && !$ctrl.monthly">
11-
<oui-select-picker-section data-ng-if="$ctrl.flavor">
11+
<oui-select-picker-section data-ng-if="$ctrl.prices">
1212
<span
1313
data-translate="pci_project_flavors_billing_price_monthly"
14-
data-translate-values="{ price: ($ctrl.getPrice($ctrl.flavor.prices.monthly) | currency: $ctrl.flavor.prices.currencyCode) }">
14+
data-translate-values="{ price: $ctrl.formatPrice($ctrl.prices.monthly) }">
1515
</span>
1616
</oui-select-picker-section>
1717
</oui-select-picker>
@@ -24,10 +24,10 @@
2424
data-variant="light"
2525
data-on-change="$ctrl.selectBilling(modelValue)"
2626
data-disabled="$ctrl.disabled && $ctrl.monthly">
27-
<oui-select-picker-section data-ng-if="$ctrl.flavor">
27+
<oui-select-picker-section data-ng-if="$ctrl.prices">
2828
<span
2929
data-translate="pci_project_flavors_billing_price_hourly"
30-
data-translate-values="{ price: ($ctrl.getPrice($ctrl.flavor.prices.hourly) | currency: $ctrl.flavor.prices.currencyCode) }">
30+
data-translate-values="{ price: $ctrl.formatPrice($ctrl.prices.hourly) }">
3131
</span>
3232
</oui-select-picker-section>
3333
</oui-select-picker>

0 commit comments

Comments
 (0)