From dccca518da5e8abe7f6e4a5a3466217affb34878 Mon Sep 17 00:00:00 2001 From: VitaliiShpital Date: Wed, 12 Feb 2020 15:30:28 +0200 Subject: [PATCH] web/satellite: shortened token payments dropdown bug fix Change-Id: Ie4a77cf88fcdc5a730a23e878481277ddf6cdb79 --- .../billing/paymentMethods/PaymentMethods.vue | 37 ++++++++++--------- .../billing/paymentMethods/PaymentsBonus.vue | 14 ++++++- .../paymentMethods/TokenDepositSelection.vue | 11 +++++- .../src/components/header/AccountDropdown.vue | 1 + .../components/project/NewProjectPopup.vue | 1 + 5 files changed, 44 insertions(+), 20 deletions(-) diff --git a/web/satellite/src/components/account/billing/paymentMethods/PaymentMethods.vue b/web/satellite/src/components/account/billing/paymentMethods/PaymentMethods.vue index 525153d05..1c4a8079e 100644 --- a/web/satellite/src/components/account/billing/paymentMethods/PaymentMethods.vue +++ b/web/satellite/src/components/account/billing/paymentMethods/PaymentMethods.vue @@ -44,7 +44,7 @@
loading gif
@@ -67,7 +67,7 @@ />
loading gif
@@ -110,6 +110,7 @@ const { GET_CREDIT_CARDS, MAKE_TOKEN_DEPOSIT, GET_BILLING_HISTORY, + GET_BALANCE, } = PAYMENTS_ACTIONS; interface StripeForm { @@ -131,8 +132,7 @@ export default class PaymentMethods extends Vue { private readonly MAX_TOKEN_AMOUNT_IN_DOLLARS = 1000000; private tokenDepositValue: number = this.DEFAULT_TOKEN_DEPOSIT_VALUE; - public isAddingCardLoading: boolean = false; - public isTransactionLoading: boolean = false; + public isLoading: boolean = false; /** * Lifecycle hook after initial render where credit cards are fetched. @@ -219,6 +219,8 @@ export default class PaymentMethods extends Vue { * Changes area state and token deposit value to default. */ public onCancel(): void { + if (this.isLoading) return; + this.areaState = PaymentMethodsBlockState.DEFAULT; this.tokenDepositValue = this.DEFAULT_TOKEN_DEPOSIT_VALUE; } @@ -228,15 +230,15 @@ export default class PaymentMethods extends Vue { * payment and return state to default */ public async onConfirmAddSTORJ(): Promise { - if (this.isTransactionLoading) return; + if (this.isLoading) return; - this.isTransactionLoading = true; + this.isLoading = true; if (this.tokenDepositValue >= this.MAX_TOKEN_AMOUNT_IN_DOLLARS || this.tokenDepositValue === 0) { await this.$notify.error('Deposit amount must be more than 0 and less than 1000000'); this.tokenDepositValue = this.DEFAULT_TOKEN_DEPOSIT_VALUE; this.areaState = PaymentMethodsBlockState.DEFAULT; - this.isTransactionLoading = false; + this.isLoading = false; return; } @@ -250,7 +252,7 @@ export default class PaymentMethods extends Vue { } } catch (error) { await this.$notify.error(error.message); - this.isTransactionLoading = false; + this.isLoading = false; } this.$segment.track(SegmentEvent.PAYMENT_METHOD_ADDED, { @@ -262,11 +264,11 @@ export default class PaymentMethods extends Vue { await this.$store.dispatch(GET_BILLING_HISTORY); } catch (error) { await this.$notify.error(error.message); - this.isTransactionLoading = false; + this.isLoading = false; } this.areaState = PaymentMethodsBlockState.DEFAULT; - this.isTransactionLoading = false; + this.isLoading = false; } /** @@ -277,6 +279,7 @@ export default class PaymentMethods extends Vue { try { await this.$store.dispatch(GET_BILLING_HISTORY); + await this.$store.dispatch(GET_BALANCE); } catch (error) { await this.$notify.error(error.message); } @@ -292,16 +295,16 @@ export default class PaymentMethods extends Vue { * @param token from Stripe */ public async addCard(token: string) { - if (this.isAddingCardLoading) return; + if (this.isLoading) return; - this.isAddingCardLoading = true; + this.isLoading = true; try { await this.$store.dispatch(ADD_CREDIT_CARD, token); } catch (error) { await this.$notify.error(error.message); - this.isAddingCardLoading = false; + this.isLoading = false; return; } @@ -314,12 +317,12 @@ export default class PaymentMethods extends Vue { await this.$store.dispatch(GET_CREDIT_CARDS); } catch (error) { await this.$notify.error(error.message); - this.isAddingCardLoading = false; + this.isLoading = false; } this.areaState = PaymentMethodsBlockState.DEFAULT; - this.isAddingCardLoading = false; + this.isLoading = false; } } diff --git a/web/satellite/src/components/account/billing/paymentMethods/PaymentsBonus.vue b/web/satellite/src/components/account/billing/paymentMethods/PaymentsBonus.vue index d61bd1f60..931b9aeb2 100644 --- a/web/satellite/src/components/account/billing/paymentMethods/PaymentsBonus.vue +++ b/web/satellite/src/components/account/billing/paymentMethods/PaymentsBonus.vue @@ -3,8 +3,8 @@