@@ -26,7 +28,11 @@
-
+
@@ -57,6 +63,7 @@ import DashboardNavbar from './DashboardNavbar.vue'
import ContentFooter from './ContentFooter.vue'
// import DashboardContent from './Content.vue';
import { FadeTransition } from 'vue2-transitions'
+import communityAPI from '../../apis/communityAPI'
export default {
components: {
@@ -65,6 +72,12 @@ export default {
// DashboardContent,
FadeTransition,
},
+ data() {
+ return {
+ balance: 0,
+ GdtBalance: 0,
+ }
+ },
methods: {
initScrollbar() {
let isWindows = navigator.platform.startsWith('Win')
@@ -78,10 +91,33 @@ export default {
this.$store.dispatch('logout')
this.$router.push('/login')
},
+ async loadBalance() {
+ const result = await communityAPI.balance(this.$store.state.session_id)
+ if (result.success) {
+ this.balance = result.result.data.balance / 10000
+ } else {
+ // what to do when loading balance fails?
+ }
+ },
+ async loadGDTBalance() {
+ const result = await communityAPI.transactions(this.$store.state.session_id)
+ if (result.success) {
+ this.GdtBalance = result.result.data.gdtSum / 10000
+ } else {
+ // what to do when loading balance fails?
+ }
+ },
+ updateBalance(ammount) {
+ this.balance -= ammount
+ },
},
mounted() {
this.initScrollbar()
},
+ created() {
+ this.loadBalance()
+ this.loadGDTBalance()
+ },
}
diff --git a/frontend/src/views/Pages/KontoOverview.spec.js b/frontend/src/views/Pages/KontoOverview.spec.js
index d2bb8403c..b0385cbc3 100644
--- a/frontend/src/views/Pages/KontoOverview.spec.js
+++ b/frontend/src/views/Pages/KontoOverview.spec.js
@@ -1,26 +1,17 @@
import { shallowMount } from '@vue/test-utils'
import KontoOverview from './KontoOverview'
-import Vuex from 'vuex'
const localVue = global.localVue
describe('KontoOverview', () => {
let wrapper
- let actions = {
- accountBalance: jest.fn(),
- }
-
- let store = new Vuex.Store({
- actions,
- })
-
let mocks = {
$t: jest.fn((t) => t),
}
const Wrapper = () => {
- return shallowMount(KontoOverview, { localVue, store, mocks })
+ return shallowMount(KontoOverview, { localVue, mocks })
}
describe('shallow Mount', () => {
@@ -44,37 +35,34 @@ describe('KontoOverview', () => {
expect(wrapper.find('gdd-table-stub').exists()).toBeTruthy()
})
- it('calls "accountBalance" action from store on creation', () => {
- const spy = jest.spyOn(actions, 'accountBalance')
- expect(spy).toHaveBeenCalled()
- })
-
it('updates transctions data when change-transactions is emitted', async () => {
wrapper.find('gdd-table-stub').vm.$emit('change-transactions', [0, 1])
await wrapper.vm.$nextTick()
expect(wrapper.vm.transactions).toEqual(expect.arrayContaining([0, 1]))
})
- describe('setRows method', () => {
+ describe('updateBalance method', () => {
beforeEach(async () => {
- wrapper.find('gdd-send-stub').vm.$emit('change-rows', {
- row_form: false,
- row_check: true,
- row_thx: true,
+ wrapper.find('gdd-send-stub').vm.$emit('update-balance', {
+ ammount: 42,
})
await wrapper.vm.$nextTick()
})
- it('updates row_form data when change-rows is emitted', () => {
- expect(wrapper.vm.row_form).toBeFalsy()
+ it('emmits updateBalance with correct value', () => {
+ expect(wrapper.emitted('update-balance')).toEqual([[42]])
+ })
+ })
+
+ describe('toggleShowList method', () => {
+ beforeEach(async () => {
+ wrapper.setProps({ showTransactionList: false })
+ wrapper.find('gdd-send-stub').vm.$emit('toggle-show-list', true)
+ await wrapper.vm.$nextTick()
})
- it('updates row_check data when change-rows is emitted', () => {
- expect(wrapper.vm.row_check).toBeTruthy()
- })
-
- it('updates row_thx data when change-rows is emitted', () => {
- expect(wrapper.vm.row_thx).toBeTruthy()
+ it('changes the value of property showTransactionList', () => {
+ expect(wrapper.vm.showTransactionList).toBeTruthy()
})
})
})
diff --git a/frontend/src/views/Pages/KontoOverview.vue b/frontend/src/views/Pages/KontoOverview.vue
index 10942b7f5..e05a6236d 100644
--- a/frontend/src/views/Pages/KontoOverview.vue
+++ b/frontend/src/views/Pages/KontoOverview.vue
@@ -2,17 +2,21 @@
-
+
@@ -28,25 +32,25 @@ export default {
name: 'Overview',
data() {
return {
- row_form: true,
- row_check: false,
- row_thx: false,
transactions: [],
+ showTransactionList: true,
}
},
+ props: {
+ balance: { type: Number, default: 0 },
+ GdtBalance: { type: Number, default: 0 },
+ },
components: {
GddStatus,
GddSend,
GddTable,
},
- created() {
- this.$store.dispatch('accountBalance', this.$store.state.session_id)
- },
methods: {
- setRows(rows) {
- this.row_form = rows.row_form
- this.row_check = rows.row_check
- this.row_thx = rows.row_thx
+ toggleShowList(bool) {
+ this.showTransactionList = bool
+ },
+ updateBalance(data) {
+ this.$emit('update-balance', data.ammount)
},
setTransactions(transactions) {
this.transactions = transactions
diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue
index f7c002d2a..4e715875d 100755
--- a/frontend/src/views/Pages/Login.vue
+++ b/frontend/src/views/Pages/Login.vue
@@ -67,7 +67,7 @@
-
+
{{ $t('site.login.signin') }}
@@ -82,7 +82,7 @@
{{ $t('site.login.forgot_pwd') }}
-
+
{{ $t('site.login.new_wallet') }}
@@ -95,6 +95,7 @@