2020-11-10 00:33:55 +00:00
|
|
|
<template>
|
2021-01-21 14:32:13 +00:00
|
|
|
<q-card style="text-align: center">
|
2020-11-10 00:33:55 +00:00
|
|
|
<q-card-section>
|
|
|
|
<div class="text-h6">Gerücht: {{ balance.toFixed(2) }} €</div>
|
|
|
|
</q-card-section>
|
|
|
|
</q-card>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { computed, defineComponent, onBeforeMount } from '@vue/composition-api';
|
2021-01-26 15:37:45 +00:00
|
|
|
import { StateInterfaceBalance } from 'src/plugins/balance/store/balance';
|
2020-11-10 00:33:55 +00:00
|
|
|
import { Store } from 'vuex';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'BalanceWidget',
|
|
|
|
setup(_, { root }) {
|
|
|
|
onBeforeMount(() => {
|
|
|
|
store.dispatch('balance/getBalance').catch(err => {
|
|
|
|
console.warn(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-01-21 14:32:13 +00:00
|
|
|
const store = <Store<StateInterfaceBalance>>root.$store;
|
2020-11-10 00:33:55 +00:00
|
|
|
|
2021-01-21 14:32:13 +00:00
|
|
|
const balance = computed(
|
|
|
|
() =>
|
|
|
|
store.state.balance.balances.get((<FG.User>store.state.user.currentUser).userid)?.balance ||
|
|
|
|
NaN
|
|
|
|
);
|
2020-11-10 00:33:55 +00:00
|
|
|
|
|
|
|
return { balance };
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|