From 7bb2b0fe7274559cda1ed16e78516110d6ea7cc6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 18 Apr 2022 19:54:17 +0200 Subject: [PATCH] pinia: Update some components to use botStore --- src/components/ftbot/Balance.vue | 40 ++++++++++---------- src/components/ftbot/BotStatus.vue | 58 +++++++++++++++-------------- src/components/layout/NavFooter.vue | 40 ++++++++++++++------ 3 files changed, 79 insertions(+), 59 deletions(-) diff --git a/src/components/ftbot/Balance.vue b/src/components/ftbot/Balance.vue index 79bb4873..36e72d91 100644 --- a/src/components/ftbot/Balance.vue +++ b/src/components/ftbot/Balance.vue @@ -2,7 +2,9 @@
- +
-

- {{ balance.note }} +

+ {{ botStore.activeBot.balance.note }}

@@ -41,40 +43,40 @@ import HideIcon from 'vue-material-design-icons/EyeOff.vue'; import ShowIcon from 'vue-material-design-icons/Eye.vue'; import BalanceChart from '@/components/charts/BalanceChart.vue'; -import { BotStoreGetters } from '@/store/modules/ftbot'; -import StoreModules from '@/store/storeSubModules'; import { formatPercent } from '@/shared/formatters'; import { defineComponent, computed, ref } from '@vue/composition-api'; -import { useNamespacedActions, useNamespacedGetters } from 'vuex-composition-helpers'; +import { useBotStore } from '@/stores/ftbotwrapper'; export default defineComponent({ name: 'Balance', components: { HideIcon, ShowIcon, BalanceChart }, setup() { - const { balance, stakeCurrencyDecimals } = useNamespacedGetters(StoreModules.ftbot, [ - BotStoreGetters.balance, - BotStoreGetters.stakeCurrencyDecimals, - ]); - const { getBalance } = useNamespacedActions(StoreModules.ftbot, ['getBalance']); + const botStore = useBotStore(); const hideSmallBalances = ref(true); const smallBalance = computed((): number => { - return Number((0.1 ** stakeCurrencyDecimals.value).toFixed(8)); + return Number((0.1 ** botStore.activeBot.stakeCurrencyDecimals).toFixed(8)); }); const balanceCurrencies = computed(() => { if (!hideSmallBalances.value) { - return balance.value.currencies; + return botStore.activeBot.balance.currencies; } - return balance.value?.currencies?.filter((v) => v.est_stake >= smallBalance.value); + return botStore.activeBot.balance.currencies?.filter( + (v) => v.est_stake >= smallBalance.value, + ); }); const tableFields = computed(() => { return [ { key: 'currency', label: 'Currency' }, { key: 'free', label: 'Available', formatter: 'formatCurrency' }, - { key: 'est_stake', label: `in ${balance.value.stake}`, formatter: 'formatCurrency' }, + { + key: 'est_stake', + label: `in ${botStore.activeBot.balance.stake}`, + formatter: 'formatCurrency', + }, ]; }); @@ -83,10 +85,8 @@ export default defineComponent({ }; return { - balance, - stakeCurrencyDecimals, + botStore, hideSmallBalances, - getBalance, formatPercent, smallBalance, balanceCurrencies, diff --git a/src/components/ftbot/BotStatus.vue b/src/components/ftbot/BotStatus.vue index bd00e8b0..15e2bc19 100644 --- a/src/components/ftbot/BotStatus.vue +++ b/src/components/ftbot/BotStatus.vue @@ -1,67 +1,71 @@