web/satellite: fixed balance inconsistency for billing tabs
Made overview tab always fetch account balance on mount. Made payment methods tab always fetch wallet (which includes wallet balance) on mount. Account and Wallet balances are queried from transactionsDB so there is no inconsistency on backend side. Issue: https://github.com/storj/storj/issues/6093 Change-Id: Ifb63d20040acf03d60ad08eac51b0f20b5b7365d
This commit is contained in:
parent
3216674c19
commit
013ddbc57f
@ -40,21 +40,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { RouteConfig } from '@/types/router';
|
import { RouteConfig } from '@/types/router';
|
||||||
import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames';
|
|
||||||
import { APP_STATE_DROPDOWNS } from '@/utils/constants/appStatePopUps';
|
import { APP_STATE_DROPDOWNS } from '@/utils/constants/appStatePopUps';
|
||||||
import { NavigationLink } from '@/types/navigation';
|
import { NavigationLink } from '@/types/navigation';
|
||||||
import { useNotify } from '@/utils/hooks';
|
import { useNotify } from '@/utils/hooks';
|
||||||
import { useBillingStore } from '@/store/modules/billingStore';
|
|
||||||
import { useAppStore } from '@/store/modules/appStore';
|
import { useAppStore } from '@/store/modules/appStore';
|
||||||
import { useAnalyticsStore } from '@/store/modules/analyticsStore';
|
import { useAnalyticsStore } from '@/store/modules/analyticsStore';
|
||||||
|
|
||||||
const analyticsStore = useAnalyticsStore();
|
const analyticsStore = useAnalyticsStore();
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const billingStore = useBillingStore();
|
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -141,21 +139,6 @@ function routeToCoupons(): void {
|
|||||||
router.push(couponsPath);
|
router.push(couponsPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Mounted lifecycle hook after initial render.
|
|
||||||
* Fetches account balance and credit cards.
|
|
||||||
*/
|
|
||||||
onMounted(async (): Promise<void> => {
|
|
||||||
try {
|
|
||||||
await Promise.all([
|
|
||||||
billingStore.getBalance(),
|
|
||||||
billingStore.getCreditCards(),
|
|
||||||
]);
|
|
||||||
} catch (error) {
|
|
||||||
notify.notifyError(error, AnalyticsErrorEventSource.BILLING_AREA);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@ -178,7 +178,10 @@ function balanceClicked(): void {
|
|||||||
*/
|
*/
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
await projectsStore.getProjects();
|
await Promise.all([
|
||||||
|
projectsStore.getProjects(),
|
||||||
|
billingStore.getBalance(),
|
||||||
|
]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notify.notifyError(error, AnalyticsErrorEventSource.BILLING_OVERVIEW_TAB);
|
notify.notifyError(error, AnalyticsErrorEventSource.BILLING_OVERVIEW_TAB);
|
||||||
isDataFetching.value = false;
|
isDataFetching.value = false;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
/>
|
/>
|
||||||
<add-token-card-native
|
<add-token-card-native
|
||||||
v-else-if="nativeTokenPaymentsEnabled"
|
v-else-if="nativeTokenPaymentsEnabled"
|
||||||
|
:parent-init-loading="parentInitLoading"
|
||||||
@showTransactions="showTransactionsTable"
|
@showTransactions="showTransactionsTable"
|
||||||
/>
|
/>
|
||||||
<add-token-card
|
<add-token-card
|
||||||
@ -196,6 +197,7 @@ import { MODALS } from '@/utils/constants/appStatePopUps';
|
|||||||
import { DEFAULT_PAGE_LIMIT } from '@/types/pagination';
|
import { DEFAULT_PAGE_LIMIT } from '@/types/pagination';
|
||||||
import { useAnalyticsStore } from '@/store/modules/analyticsStore';
|
import { useAnalyticsStore } from '@/store/modules/analyticsStore';
|
||||||
import { useCreateProjectClickHandler } from '@/composables/useCreateProjectClickHandler';
|
import { useCreateProjectClickHandler } from '@/composables/useCreateProjectClickHandler';
|
||||||
|
import { useLoading } from '@/composables/useLoading';
|
||||||
|
|
||||||
import VButton from '@/components/common/VButton.vue';
|
import VButton from '@/components/common/VButton.vue';
|
||||||
import VLoader from '@/components/common/VLoader.vue';
|
import VLoader from '@/components/common/VLoader.vue';
|
||||||
@ -235,6 +237,7 @@ const appStore = useAppStore();
|
|||||||
const projectsStore = useProjectsStore();
|
const projectsStore = useProjectsStore();
|
||||||
|
|
||||||
const { handleCreateProjectClick } = useCreateProjectClickHandler();
|
const { handleCreateProjectClick } = useCreateProjectClickHandler();
|
||||||
|
const { isLoading: parentInitLoading, withLoading } = useLoading();
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -479,12 +482,23 @@ function paginationController(page: number, limit: number): void {
|
|||||||
displayedHistory.value = nativePaymentHistoryItems.value.slice((page - 1) * limit, ((page - 1) * limit) + limit);
|
displayedHistory.value = nativePaymentHistoryItems.value.slice((page - 1) * limit, ((page - 1) * limit) + limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted((): void => {
|
onMounted(async (): Promise<void> => {
|
||||||
defaultCreditCardSelection.value = creditCards.value.find(c => c.isDefault)?.id ?? '';
|
defaultCreditCardSelection.value = creditCards.value.find(c => c.isDefault)?.id ?? '';
|
||||||
|
|
||||||
if (route.query.action === 'token history') {
|
if (route.query.action === 'token history') {
|
||||||
showTransactionsTable();
|
showTransactionsTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await withLoading(async () => {
|
||||||
|
try {
|
||||||
|
await Promise.all([
|
||||||
|
billingStore.getWallet(),
|
||||||
|
billingStore.getCreditCards(),
|
||||||
|
]);
|
||||||
|
} catch (error) {
|
||||||
|
notify.notifyError(error, AnalyticsErrorEventSource.BILLING_PAYMENT_METHODS_TAB);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="token__content">
|
<div class="token__content">
|
||||||
<div v-if="isLoading" class="token__content__loader-container">
|
<div v-if="isLoading || parentInitLoading" class="token__content__loader-container">
|
||||||
<v-loader />
|
<v-loader />
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="!wallet.address" class="token__content__add-funds">
|
<div v-else-if="!wallet.address" class="token__content__add-funds">
|
||||||
@ -119,6 +119,10 @@ const notify = useNotify();
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
parentInitLoading: boolean
|
||||||
|
}>();
|
||||||
|
|
||||||
const isLoading = ref<boolean>(false);
|
const isLoading = ref<boolean>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,19 +139,6 @@ const wallet = computed((): Wallet => {
|
|||||||
return billingStore.state.wallet as Wallet;
|
return billingStore.state.wallet as Wallet;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* getWallet tries to get an existing wallet for this user. this will not claim a wallet.
|
|
||||||
*/
|
|
||||||
async function getWallet(): Promise<void> {
|
|
||||||
if (wallet.value.address) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isLoading.value = true;
|
|
||||||
await billingStore.getWallet().catch(_ => {});
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* claimWallet claims a wallet for the current account.
|
* claimWallet claims a wallet for the current account.
|
||||||
*/
|
*/
|
||||||
@ -189,8 +180,6 @@ function onAddTokensClick(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async (): Promise<void> => {
|
onMounted(async (): Promise<void> => {
|
||||||
await getWallet();
|
|
||||||
|
|
||||||
// check if user navigated here from Billing overview screen
|
// check if user navigated here from Billing overview screen
|
||||||
if (route.query.action !== 'add tokens') {
|
if (route.query.action !== 'add tokens') {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user