Ver código fonte

show promos on new network page. minor cleanups

pull/1/head
Jonathan Cobb 4 anos atrás
pai
commit
cb7bdfea11
4 arquivos alterados com 49 adições e 20 exclusões
  1. +5
    -0
      src/_services/paymentMethod.service.js
  2. +25
    -3
      src/_store/paymentMethods.module.js
  3. +18
    -16
      src/account/NewNetworkPage.vue
  4. +1
    -1
      webpack.config.js

+ 5
- 0
src/_services/paymentMethod.service.js Ver arquivo

@@ -14,6 +14,7 @@ export const paymentMethodService = {
addAccountPaymentMethod,
setAccountPaymentMethodForPlan,
deleteAccountPaymentMethod,
getPromosByAccount
};

function getAllPaymentMethods(messages, errors) {
@@ -53,3 +54,7 @@ function setAccountPaymentMethodForPlan(userId, planId, pmId, messages, errors)
function deleteAccountPaymentMethod(userId, pmId, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/paymentMethods/${pmId}`, util.deleteWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getPromosByAccount(userId, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/promos`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

+ 25
- 3
src/_store/paymentMethods.module.js Ver arquivo

@@ -9,7 +9,7 @@ const state = {
loading: {
paymentMethods: false, paymentMethod: false,
accountPaymentMethods: false, accountPaymentMethod: false,
adding: false, updating: false, deleting: false
adding: false, updating: false, deleting: false, promos: false
},
paymentStatus: {},
error: null,
@@ -19,7 +19,8 @@ const state = {
paymentInfo: null,
accountPaymentMethods: null,
accountPaymentMethod: null,
accountPaymentUuid: null
accountPaymentUuid: null,
promos: null
};

const actions = {
@@ -98,7 +99,16 @@ const actions = {
},
clearPaymentInfo({ commit }) {
commit('clearPaymentInfoSuccess');
}
},

getPromosByAccount({ commit }, {userId, messages, errors}) {
commit('getPromosByAccountRequest');
paymentMethodService.getPromosByAccount(userId, messages, errors)
.then(
promos => commit('getPromosByAccountSuccess', promos),
error => commit('getPromosByAccountFailure', error)
);
},
};

const mutations = {
@@ -217,6 +227,18 @@ const mutations = {

clearPaymentInfoSuccess(state) {
state.paymentInfo = null;
},

getPromosByAccountRequest(state) {
state.loading.promos = true;
},
getPromosByAccountSuccess(state, promos) {
state.loading.promos = false;
state.promos = promos;
},
getPromosByAccountFailure(state, error) {
state.loading.promos = false;
state.error = { error };
}
};



+ 18
- 16
src/account/NewNetworkPage.vue Ver arquivo

@@ -281,10 +281,21 @@
</div>

<div>
<label for="showAdvanced">{{messages.field_label_show_advanced_plan_options}}</label>
<label for="showAdvanced"><b>{{messages.field_label_show_advanced_plan_options}}</b></label>
<input type="checkbox" name="showAdvanced" v-model="showAdvanced"/>
</div>

<hr/>
<div v-if="promos">
<h5>{{messages.title_account_promotions}}</h5>
<table border="0">
<tr v-for="promo in promos">
<td><b>{{messages['label_promotion_'+promo.name]}}</b>:</td>
<td>{{messages['label_promotion_'+promo.name+'_description']}}</td>
</tr>
</table>
<hr/>
</div>

<div class="form-group">
<button class="btn btn-primary" :disabled="loading() || !isComplete" @click="launchBubble()">{{messages.button_label_create_new_network}}</button>
@@ -366,7 +377,7 @@
...mapState('apps', ['icons']),
...mapState('footprints', ['footprints']),
...mapState('paymentMethods', [
'paymentMethods', 'accountPaymentMethods', 'accountPaymentMethod', 'paymentMethod', 'paymentInfo'
'paymentMethods', 'accountPaymentMethods', 'accountPaymentMethod', 'paymentMethod', 'paymentInfo', 'promos'
]),
...mapState('networks', ['nearestRegions', 'newNodeNotification']),
...mapState('networks', {
@@ -379,17 +390,7 @@
&& this.user && this.user.admin === true;
},
isComplete() {
// return (this.accountPlan.name !== '' || this.accountPlan.forkHost !== '')
// && (this.customize.domain === false || this.accountPlan.domain !== '')
// && (this.customize.locale === false || this.accountPlan.locale !== '')
// && (this.customize.timezone === false || this.accountPlan.timezone !== '')
// && (this.customize.plan === false || this.accountPlan.plan !== '')
// && (this.customize.footprint === false || this.accountPlan.footprint !== '')
// && (
// (this.accountPlan.paymentMethodObject.paymentMethodType != null) && (this.accountPlan.paymentMethodObject.paymentInfo != null)
// || (this.accountPlan.paymentMethodObject.uuid != null)
// );
const complete = (this.accountPlan.name !== '' || this.accountPlan.forkHost !== '')
return (this.accountPlan.name !== '' || this.accountPlan.forkHost !== '')
&& (this.customize.domain === false || this.accountPlan.domain !== '')
&& (this.customize.locale === false || this.accountPlan.locale !== '')
&& (this.customize.timezone === false || this.accountPlan.timezone !== '')
@@ -399,8 +400,6 @@
(this.accountPlan.paymentMethodObject.paymentMethodType != null) && (this.accountPlan.paymentMethodObject.paymentInfo != null)
|| (this.accountPlan.paymentMethodObject.uuid != null)
);
console.log('isComplete: returning '+complete+', this.accountPlan.name='+this.accountPlan.name+', this.accountPlan.paymentMethodObject.uuid='+this.accountPlan.paymentMethodObject.uuid);
return complete;
},
timezoneObjects: function () {
const tz_objects = [];
@@ -468,7 +467,9 @@
...mapActions('plans', ['getAllPlans']),
...mapActions('apps', ['getAppsByUserId']),
...mapActions('footprints', ['getAllFootprints']),
...mapActions('paymentMethods', ['getAllPaymentMethods', 'getAllAccountPaymentMethods', 'setPaymentMethod']),
...mapActions('paymentMethods', [
'getAllPaymentMethods', 'getAllAccountPaymentMethods', 'setPaymentMethod', 'getPromosByAccount'
]),

initDefaults() {
const currentUser = util.currentUser();
@@ -487,6 +488,7 @@
this.getAllAccountPaymentMethods({userId: currentUser.uuid, messages: this.messages, errors: this.errors});
this.listSshKeysByUserId({userId: currentUser.uuid, messages: this.messages, errors: this.errors});
this.getNearestRegions({footprintId: null, messages: this.messages, errors: this.errors});
this.getPromosByAccount({userId: currentUser.uuid, messages: this.messages, errors: this.errors});
},
isAuthenticator(val) { return window.isAuthenticator(val); },
isNotAuthenticator(val) { return window.isNotAuthenticator(val); },


+ 1
- 1
webpack.config.js Ver arquivo

@@ -44,7 +44,7 @@ module.exports = {
externals: {
// global app config object
config: JSON.stringify({
// production: true,
production: true,
apiUrl: '/api'
})
}


Carregando…
Cancelar
Salvar