diff --git a/src/_services/paymentMethod.service.js b/src/_services/paymentMethod.service.js index 619bab9..235b631 100644 --- a/src/_services/paymentMethod.service.js +++ b/src/_services/paymentMethod.service.js @@ -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)); +} diff --git a/src/_store/paymentMethods.module.js b/src/_store/paymentMethods.module.js index 8de1a05..dae86b4 100644 --- a/src/_store/paymentMethods.module.js +++ b/src/_store/paymentMethods.module.js @@ -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 }; } }; diff --git a/src/account/NewNetworkPage.vue b/src/account/NewNetworkPage.vue index cd50f03..b4f2711 100644 --- a/src/account/NewNetworkPage.vue +++ b/src/account/NewNetworkPage.vue @@ -281,10 +281,21 @@
- +
+
+
+
{{messages.title_account_promotions}}
+ + + + + +
{{messages['label_promotion_'+promo.name]}}:{{messages['label_promotion_'+promo.name+'_description']}}
+
+
@@ -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); }, diff --git a/webpack.config.js b/webpack.config.js index 21f4b77..ef5236f 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -44,7 +44,7 @@ module.exports = { externals: { // global app config object config: JSON.stringify({ - // production: true, + production: true, apiUrl: '/api' }) }