From 927a08defda4f22b35e9c2ff0befdb11213daab5 Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Tue, 26 Sep 2017 16:05:54 -0500 Subject: [PATCH] Small payment fixes (#9082) * Fixed some parameter passing and computed placements * reset edit when user change * Lint fix --- .../components/payments/sendGemsModal.vue | 4 ++-- .../components/settings/subscription.vue | 23 ++++++++++--------- .../client/components/userMenu/profile.vue | 3 +++ website/client/libs/encodeParams.js | 4 ++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/website/client/components/payments/sendGemsModal.vue b/website/client/components/payments/sendGemsModal.vue index df94a88698..ffa8aa3623 100644 --- a/website/client/components/payments/sendGemsModal.vue +++ b/website/client/components/payments/sendGemsModal.vue @@ -2,7 +2,7 @@ b-modal#send-gems(:title="title", :hide-footer="true", size='lg') .modal-body(v-if='userReceivingGems') .panel.panel-default( - :class="gift.type === 'gems' ? 'panel-primary' : 'transparent'", + :class="gift.type === 'gems' ? 'panel-primary' : 'transparent'", @click='gift.type = "gems"' ) // @TODO the panel does not exists in Bootstrap 4 @@ -27,7 +27,7 @@ b-modal#send-gems(:title="title", :hide-footer="true", size='lg') p.small(v-html="$t('gemGiftsAreOptional', assistanceEmailObject)") .panel.panel-default( - :class="gift.type=='subscription' ? 'panel-primary' : 'transparent'", + :class="gift.type=='subscription' ? 'panel-primary' : 'transparent'", @click='gift.type = "subscription"' ) h3.panel-heading {{ $t('subscription') }} diff --git a/website/client/components/settings/subscription.vue b/website/client/components/settings/subscription.vue index 538f57dcda..f1d5511fc4 100644 --- a/website/client/components/settings/subscription.vue +++ b/website/client/components/settings/subscription.vue @@ -36,11 +36,11 @@ strong {{user.purchased.plan.dateTerminated | date}} tr(v-if='!hasCanceledSubscription'): td h4 {{ $t('subscribed') }} - p(v-if='hasPlan && !hasGroupPlan') {{ $t('purchasedPlanId', {purchasedPlanIdInfo}) }} + p(v-if='hasPlan && !hasGroupPlan') {{ $t('purchasedPlanId', purchasedPlanIdInfo) }} p(v-if='hasGroupPlan') {{ $t('youHaveGroupPlan') }} tr(v-if='user.purchased.plan.extraMonths'): td span.glyphicon.glyphicon-credit-card - |   {{ $t('purchasedPlanExtraMonths', {purchasedPlanExtraMonthsDetails}) }} + |   {{ $t('purchasedPlanExtraMonths', purchasedPlanExtraMonthsDetails) }} tr(v-if='hasConsecutiveSubscription'): td span.glyphicon.glyphicon-forward |   {{ $t('consecutiveSubscription') }} @@ -208,7 +208,7 @@ export default { }, purchasedPlanExtraMonthsDetails () { return { - months: this.user.purchased.plan.extraMonths.toFixed(2), + months: parseFloat(this.user.purchased.plan.extraMonths).toFixed(2), }; }, buyGemsGoldCap () { @@ -238,6 +238,14 @@ export default { amount: this.numberOfMysticHourglasses, }; }, + canCancelSubscription () { + return ( + this.user.purchased.plan.paymentMethod !== this.paymentMethods.GOOGLE && + this.user.purchased.plan.paymentMethod !== this.paymentMethods.APPLE && + !this.hasCanceledSubscription && + !this.hasGroupPlan + ); + }, }, methods: { async applyCoupon (coupon) { @@ -253,14 +261,6 @@ export default { subs.basic_6mo.discount = true; subs.google_6mo.discount = false; }, - canCancelSubscription () { - return ( - this.user.purchased.plan.paymentMethod !== this.paymentMethods.GOOGLE && - this.user.purchased.plan.paymentMethod !== this.paymentMethods.APPLE && - !this.hasCanceledSubscription && - !this.hasGroupPlan - ); - }, async cancelSubscription (config) { if (config && config.group && !confirm(this.$t('confirmCancelGroupPlan'))) return; if (!confirm(this.$t('sureCancelSub'))) return; @@ -298,6 +298,7 @@ export default { this.$router.push('/'); }, getCancelSubInfo () { + // @TODO: String 'cancelSubInfoGroup Plan' not found. ? return this.$t(`cancelSubInfo${this.user.purchased.plan.paymentMethod}`); }, }, diff --git a/website/client/components/userMenu/profile.vue b/website/client/components/userMenu/profile.vue index 8f1ed84bed..bdfa5ccaff 100644 --- a/website/client/components/userMenu/profile.vue +++ b/website/client/components/userMenu/profile.vue @@ -653,6 +653,9 @@ export default { user () { let user = this.userLoggedIn; + // Reset editing when user is changed. Move to watch or is this good? + this.editing = false; + let profileUser = this.$store.state.profileUser; if (profileUser._id && profileUser._id !== this.userLoggedIn._id) { user = profileUser; diff --git a/website/client/libs/encodeParams.js b/website/client/libs/encodeParams.js index ac675bfe1c..1666e92fa5 100644 --- a/website/client/libs/encodeParams.js +++ b/website/client/libs/encodeParams.js @@ -1,7 +1,7 @@ // Equivalent of jQuery's param export default function (params) { - Object.keys(params).map((k) => { + return Object.keys(params).map((k) => { return `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`; }).join('&'); -} \ No newline at end of file +}