Skip to content

Commit

Permalink
Merge pull request #217 from Support-pl/dev
Browse files Browse the repository at this point in the history
fixed periods and filtering plans when creating
  • Loading branch information
639852 committed Jun 28, 2023
2 parents 204bff7 + f65968f commit 4b31eb7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/components/appMain/modules/ione/createInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,14 @@ export default {
watch: {
plans() {
const value = [];
const types = new Set();
const day = 3600 * 24
const month = day * 30;
const year = day * 365;
this.plans.forEach((plan) => {
types.add(plan.type);
if (plan.kind === 'DYNAMIC') value.push(
{ value: 'Hourly', label: 'ssl_product.Hourly' }
);
Expand All @@ -470,6 +473,8 @@ export default {
{ value: 'Biennially', label: 'biennially', period: year * 2 }
);
});
if (types.size > 1) return;
value.sort((a, b) => (a.value === 'Hourly') ? 1 : a.period - b.period);
this.options.drive = false;
Expand Down
2 changes: 2 additions & 0 deletions src/components/appMain/modules/ovh cloud/createInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export default {
this.$emit('setData', { key: 'priceOVH', value: this.price });
this.$emit('setData', { key: 'planCode', value, type: 'ovh' });
this.$emit('setData', { key: 'monthlyBilling', value: (plan.duration === 'P1M'), type: 'ovh' });
this.$emit('setData', { key: 'duration', value: plan.duration, type: 'ovh' });
this.$emit('setData', { key: 'pricingMode', value: plan.pricingMode, type: 'ovh' });
},
setPlans(value) {
this.plans = value.sort((a, b) =>
Expand Down
26 changes: 17 additions & 9 deletions src/components/appMain/newPaaS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
ref="sum-order"
:style="{ 'font-size': '1.4rem', 'margin-top': '10px' }"
>
<a-col style="margin-right: 4px" v-if="activeKey === 'location'">
<a-col style="margin-right: 4px" v-if="activeKey === 'location' && tarification">
{{ $t('from') | capitalize }}:
</a-col>
<transition name="textchange" mode="out-in">
Expand Down Expand Up @@ -824,10 +824,11 @@ export default {
//--------------Plans-----------------
filteredPlans() {
const { billing_plans = [] } = (this.itemSP.meta.showcase ?? {})[this.showcase] ?? {};
const locationItem = this.locations.find((el) => el.id === this.locationId);
if (billing_plans.length < 1) return this.getPlans;
return this.getPlans.filter(({ uuid }) => billing_plans?.includes(uuid));
return this.getPlans.filter(({ type }) =>
(locationItem.type) ? locationItem.type === type : true
);
},
//UNKNOWN and STATIC
getPlan() {
Expand Down Expand Up @@ -1321,6 +1322,8 @@ export default {
newGroup.config = { ssh: newInstance.config.ssh };
delete newInstance.config.ssh;
}
delete newInstance.product;
}
if (this.itemService?.instancesGroups?.length < 1) {
this.itemService.instancesGroups = [newGroup];
Expand Down Expand Up @@ -1625,13 +1628,18 @@ export default {
anonymously: !this.isLoggedIn
})
.then(({ pool }) => {
const showcase = Object.keys(this.itemSP.meta.showcase ?? {})
.find((key) => key === this.$route.query.service) ??
Object.keys(this.itemSP.meta.showcase ?? {})[0];
this.$store.commit('nocloud/plans/setPlans', pool);
const keys = Object.entries(this.itemSP.meta.showcase ?? {});
const [showcase] = keys.find(([key, { billing_plans }]) => {
const plan = this.filteredPlans.find(({ uuid }) => billing_plans.includes(uuid));
return key === this.$route.query.service || plan;
}) ?? keys[0];
const plans = this.itemSP.meta.showcase[showcase]?.billing_plans ?? [];
const uuid = plans.find((el) => pool.find((plan) => el === plan.uuid));
const uuid = plans.find((el) => this.filteredPlans.find((plan) => el === plan.uuid));
this.$store.commit('nocloud/plans/setPlans', pool);
this.plan = uuid ?? pool[0]?.uuid ?? '';
if (this.dataLocalStorage.billing_plan) {
Expand Down

0 comments on commit 4b31eb7

Please sign in to comment.