From 883a464f426e317dbefab18daf0a0812f42c8f71 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Wed, 8 Jan 2020 01:19:34 -0500 Subject: [PATCH] fix payment views and cloud/region selection --- src/_helpers/router.js | 16 +++---- src/_services/paymentMethod.service.js | 1 - src/_store/paymentMethods.module.js | 1 - src/account/NewNetworkPage.vue | 56 +++++++++++++++-------- src/account/payment/FreePayment.vue | 45 ++++++++++++++++++ src/account/payment/InviteCodePayment.vue | 2 - src/account/payment/UnknownPayment.vue | 9 ++-- 7 files changed, 93 insertions(+), 37 deletions(-) create mode 100644 src/account/payment/FreePayment.vue diff --git a/src/_helpers/router.js b/src/_helpers/router.js index b380727..bf0b42d 100644 --- a/src/_helpers/router.js +++ b/src/_helpers/router.js @@ -18,20 +18,20 @@ import NetworkPage from '../account/NetworkPage' import AccountsPage from '../admin/AccountsPage' import StripePayment from "../account/payment/StripePayment"; import InviteCodePayment from "../account/payment/InviteCodePayment"; +import FreePayment from "../account/payment/FreePayment"; import UnknownPayment from "../account/payment/UnknownPayment"; import { util } from '../_helpers' Vue.use(Router); const newNetworkChildren = [ - { path: '', component: NewNetworkPage, - children: [{ - 'path': '', components: { - 'stripe': StripePayment, - 'invite': InviteCodePayment, - 'unknown': UnknownPayment - } - }] + { path: '', components: { + default: NewNetworkPage, + pay_stripe: StripePayment, + pay_invite: InviteCodePayment, + pay_free: FreePayment, + pay_unknown: UnknownPayment + } } ]; diff --git a/src/_services/paymentMethod.service.js b/src/_services/paymentMethod.service.js index be97d26..a1f295c 100644 --- a/src/_services/paymentMethod.service.js +++ b/src/_services/paymentMethod.service.js @@ -26,6 +26,5 @@ function getByAccountAndId(paymentMethodId, messages, errors) { } function addAccountPaymentMethod(paymentMethod, messages, errors) { - console.log("pmService: paymentMethod="+JSON.stringify(paymentMethod)); return fetch(`${config.apiUrl}/me/paymentMethods`, util.putWithAuth(paymentMethod)).then(util.handleCrudResponse(messages, errors)); } diff --git a/src/_store/paymentMethods.module.js b/src/_store/paymentMethods.module.js index cfa7668..8359652 100644 --- a/src/_store/paymentMethods.module.js +++ b/src/_store/paymentMethods.module.js @@ -59,7 +59,6 @@ const actions = { }, addAccountPaymentMethod({ commit }, {paymentMethod, messages, errors}) { - console.log("pmModule: paymentMethod="+JSON.stringify(paymentMethod)); commit('addAccountPaymentMethodRequest'); paymentMethodService.addAccountPaymentMethod(paymentMethod, messages, errors) .then( diff --git a/src/account/NewNetworkPage.vue b/src/account/NewNetworkPage.vue index cf7f8d1..1080725 100644 --- a/src/account/NewNetworkPage.vue +++ b/src/account/NewNetworkPage.vue @@ -103,8 +103,8 @@
- +
{{ errors.first('region') }}
@@ -115,9 +115,6 @@
-
- {{cloudRegion.name}} -

@@ -138,6 +135,7 @@
+
@@ -148,13 +146,20 @@
-
- - +
+ + +
+
+ + +
+
+ +
-
- - +
+

@@ -185,14 +190,13 @@ locale: '', timezone: '', plan: 'bubble', - region: '', footprint: 'Worldwide', paymentMethodObject: { paymentMethodType: null, paymentInfo: null } }, - cloudRegion: '', + cloudRegionUuid: null, regions: [], customize: { domain: false, @@ -217,7 +221,8 @@ }, verifiedContacts: false, anyContacts: false, - firstContact: null + firstContact: null, + selectedPaymentMethod: null }; }, computed: { @@ -373,8 +378,14 @@ tzDescription(tz) { return this.messages['tz_name_'+tz] + " - " + this.messages['tz_description_'+tz] }, - regionId(region) { - return region.cloud+':'+region.internalName; + findRegion(uuid) { + if (this.regions) { + for (let i = 0; i < this.regions.length; i++) { + if (this.regions[i].uuid === uuid) return this.regions[i]; + } + } + console.log('findRegion: uuid not found: '+uuid); + return null; }, handleSubmit(e) { this.submitted = true; @@ -385,7 +396,13 @@ paymentMethodType: this.paymentMethod.paymentMethodType, paymentInfo: this.paymentInfo }; - this.createNewNetwork(this.network); + const cloudRegion = this.findRegion(this.cloudRegionUuid); + if (cloudRegion === null) { + console.log('no region selected'); + } else { + console.log('sending create network: ' + JSON.stringify(this.network) + ' cloud/region=' + cloudRegion.cloud + '/' + cloudRegion.internalName); + } + // this.createNewNetwork(this.network); } } }); @@ -413,12 +430,13 @@ nearestRegions (regions) { if (regions) { this.regions = regions; - if (this.network.region === '') this.network.region = this.regionId(regions[0]); + if (this.cloudRegionUuid === null) this.cloudRegionUuid = regions[0].uuid; if (this.defaults.region === '') this.defaults.region = regions[0]; } }, paymentMethod (pm) { if (pm) { + this.selectedPaymentMethod = pm; this.network.paymentMethodObject.paymentMethodType = pm.paymentMethodType; this.network.paymentMethodObject.paymentInfo = null; } @@ -429,13 +447,11 @@ } }, policy (p) { - // console.log('watch.policy: received '+JSON.stringify(p)); this.anyContacts = this.hasAnyContacts(p); this.verifiedContacts = this.hasVerifiedContact(p); this.firstContact = this.getFirstContact(p); }, actionStatus (status) { - // console.log('watch.actionStatus: received: '+JSON.stringify(status)); if (status.success) { this.initDefaults(); } diff --git a/src/account/payment/FreePayment.vue b/src/account/payment/FreePayment.vue new file mode 100644 index 0000000..fffc101 --- /dev/null +++ b/src/account/payment/FreePayment.vue @@ -0,0 +1,45 @@ + + + \ No newline at end of file diff --git a/src/account/payment/InviteCodePayment.vue b/src/account/payment/InviteCodePayment.vue index 6aa1753..e82d0d9 100644 --- a/src/account/payment/InviteCodePayment.vue +++ b/src/account/payment/InviteCodePayment.vue @@ -32,7 +32,6 @@ ...mapState('system', ['messages']), }, created () { - console.log('InviteCodePayment.vue: created, paymentMethod='+JSON.stringify(this.paymentMethod)); if (this.paymentMethod && this.paymentMethod.paymentMethodType === 'code') { this.invite_code = this.paymentInfo; } @@ -40,7 +39,6 @@ methods: { ...mapActions('paymentMethods', ['addAccountPaymentMethod']), setInviteCode: function (e) { - console.log('setInviteCode: calling setPaymentInfo with invite code: '+this.invite_code); this.submitted = true; this.errors.clear(); this.addAccountPaymentMethod({ diff --git a/src/account/payment/UnknownPayment.vue b/src/account/payment/UnknownPayment.vue index 1410d87..c25d80d 100644 --- a/src/account/payment/UnknownPayment.vue +++ b/src/account/payment/UnknownPayment.vue @@ -1,13 +1,12 @@ \ No newline at end of file