From 6109fa685dcc33c186772b402c25c55707f07ad5 Mon Sep 17 00:00:00 2001 From: VitaliiShpital Date: Wed, 8 Apr 2020 15:53:53 +0300 Subject: [PATCH] web/satellite: allow users who have balance to create projects Change-Id: I5c93dea09812fcbfcc1b7a9ca2202de3087b7032 --- web/satellite/src/components/team/HeaderArea.vue | 2 +- web/satellite/src/store/modules/payments.ts | 4 ++-- .../tests/unit/components/header/NewProjectArea.spec.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/satellite/src/components/team/HeaderArea.vue b/web/satellite/src/components/team/HeaderArea.vue index ffe188b69..14535014a 100644 --- a/web/satellite/src/components/team/HeaderArea.vue +++ b/web/satellite/src/components/team/HeaderArea.vue @@ -206,7 +206,7 @@ export default class HeaderArea extends Vue { const projects = await this.$store.dispatch(PROJECTS_ACTIONS.FETCH); if (!projects.length) { await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.LOADED_EMPTY); - await this.$router.push(RouteConfig.ProjectDashboard.path); + await this.$router.push(RouteConfig.Account.with(RouteConfig.Billing).path); return; } diff --git a/web/satellite/src/store/modules/payments.ts b/web/satellite/src/store/modules/payments.ts index 31f6225ef..49f6bd3c5 100644 --- a/web/satellite/src/store/modules/payments.ts +++ b/web/satellite/src/store/modules/payments.ts @@ -262,10 +262,10 @@ export function makePaymentsModule(api: PaymentsApi): StoreModule }, getters: { canUserCreateFirstProject: (state: PaymentsState): boolean => { - return state.billingHistory.some((billingItem: BillingHistoryItem) => { + return (state.billingHistory.some((billingItem: BillingHistoryItem) => { return billingItem.amount >= 50 && billingItem.type === BillingHistoryItemType.Transaction && billingItem.status === BillingHistoryItemStatus.Completed; - }) || state.creditCards.length > 0; + }) && state.balance > 0) || state.creditCards.length > 0; }, isInvoiceForPreviousRollup: (state: PaymentsState): boolean => { const now = new Date(); diff --git a/web/satellite/tests/unit/components/header/NewProjectArea.spec.ts b/web/satellite/tests/unit/components/header/NewProjectArea.spec.ts index 8dc506e59..6722ceddb 100644 --- a/web/satellite/tests/unit/components/header/NewProjectArea.spec.ts +++ b/web/satellite/tests/unit/components/header/NewProjectArea.spec.ts @@ -76,6 +76,7 @@ describe('NewProjectArea', () => { BillingHistoryItemStatus.Completed, 'test', new Date(), new Date(), BillingHistoryItemType.Transaction); store.commit(PAYMENTS_MUTATIONS.CLEAR); store.commit(PAYMENTS_MUTATIONS.SET_BILLING_HISTORY, [billingTransactionItem]); + store.commit(PAYMENTS_MUTATIONS.SET_BALANCE, 50); const wrapper = mount(NewProjectArea, { store,