diff --git a/src/components/Wallets/HeaderList.vue b/src/components/Wallets/HeaderList.vue new file mode 100644 index 00000000..63506f94 --- /dev/null +++ b/src/components/Wallets/HeaderList.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/src/components/Wallets/HeaderWallet.vue b/src/components/Wallets/HeaderWallet.vue index 9c14dcd4..d9ef9921 100644 --- a/src/components/Wallets/HeaderWallet.vue +++ b/src/components/Wallets/HeaderWallet.vue @@ -9,7 +9,7 @@ mdi-arrow-left - Bitcoin (Personal) + {{ name }} @@ -17,9 +17,14 @@ mdi-share-variant - - mdi-dots-vertical - + + + Settings Wallet + @@ -30,6 +35,10 @@ export default { address: { type: String, required: true + }, + name: { + type: String, + required: true } }, methods: { diff --git a/src/components/Wallets/ItemTransaction.vue b/src/components/Wallets/ItemTransaction.vue index c668d512..08bf1276 100644 --- a/src/components/Wallets/ItemTransaction.vue +++ b/src/components/Wallets/ItemTransaction.vue @@ -20,7 +20,13 @@
- +
@@ -136,7 +142,10 @@ export default { }, currentBalance() { const wallet = this.journal[0].balance.find(wall => wall.wallet === this.address) - return (wallet.balance / 10 ** this.decimal).toFixed(this.currentDecimal) + if (wallet) { + return (wallet.balance / 10 ** this.decimal).toFixed(this.currentDecimal) + } + return '' }, isReceived() { return this.to === this.address diff --git a/src/store/modules/Wallets/index.js b/src/store/modules/Wallets/index.js index 2ad8f871..0ddbfdf5 100644 --- a/src/store/modules/Wallets/index.js +++ b/src/store/modules/Wallets/index.js @@ -1,58 +1,113 @@ +import { SET_MODEL } from '@/store/common/mutations.types' +import { pickCommonMutations } from '@/store/common/mutations' + export const MODULE_NAME = 'Wallets' +export const SET_ACCOUNT_ID = 'SET_ACCOUNT_ID' +export const GET_ACCOUNT_ID = 'GET_ACCOUNT_ID' export default { state: { + model: { + accountId: null + }, list: [ { - name: 'BTC', - value: 0.056734, - icon: 'btc', - subWallets: [ + id: 'iasduah415fni1j832jh8rjnfimda0m', + name: 'Vasilii', + list: [ { - name: 'Default', + name: 'BTC', value: 0.056734, - address: '1C9Uae6kyDtPo4ykzd5AJaLzLEZSpEbP3y' - } - ] - }, - { - name: 'ETH', - value: 43.0561, - subWallets: [ - { - name: 'Default', - value: 40.0561, - address: '0xd19615f2Eab2ABfBF7ca16618b5eD43386374DD0' + icon: 'btc', + subWallets: [ + { + name: 'Default', + value: 0.056734, + address: '1C9Uae6kyDtPo4ykzd5AJaLzLEZSpEbP3y' + } + ] }, { - name: 'Swaps', - value: 3.0 + name: 'ETH', + value: 43.0561, + subWallets: [ + { + name: 'Default', + value: 40.0561, + address: '0xd19615f2Eab2ABfBF7ca16618b5eD43386374DD0' + }, + { + name: 'Swaps', + value: 3.0, + address: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D' + }, + { + name: 'Expenses', + value: 0.0, + address: '0x7a250d5630B4cF539739dF2C5dAcb4c659F24882' + } + ] }, { - name: 'Expenses', - value: 0.0 + name: 'USDT', + value: 100.1, + subWallets: [ + { + name: 'Default', + value: 100.1, + address: 'GUzPzmRhx5VgsYH3vZjGjLgtFQMHkJzyHU' + } + ] } ] }, { - name: 'USDT', - value: 100.1, - subWallets: [ + id: 'iasd123uahfni1j832jh8rjnfimda0m', + name: 'Corporat', + list: [ { - name: 'Default', - value: 100.1, - address: 'GUzPzmRhx5VgsYH3vZjGjLgtFQMHkJzyHU' + name: 'ETH', + value: 43.0561, + subWallets: [ + { + name: 'Default', + value: 40.0561, + address: '0xd19615f2Eab2ABfBF7ca16618b5eD43386374DD0' + } + ] } ] } ] }, getters: { - siblingList(state) { - return state.list.reduce((acc, el) => { + currentListWallets(state) { + const account = state.list.find(el => el.id === state.model.accountId) || {} + return account.list + }, + siblingList(state, { currentListWallets }) { + return currentListWallets?.reduce((acc, el) => { acc.push(...el.subWallets) return acc }, []) + }, + walletsSumm(state, { currentListWallets }) { + return currentListWallets?.reduce((balance, el) => { + return balance + el.value + }, 0) } + }, + actions: { + [GET_ACCOUNT_ID]({ state, commit }) { + const accountId = window.localStorage.getItem('accountId') || state.list[0].id + commit(SET_MODEL, { model: { accountId } }) + }, + [SET_ACCOUNT_ID]({ commit }, accountId) { + window.localStorage.setItem('accountId', accountId) + commit(SET_MODEL, { model: { accountId } }) + } + }, + mutations: { + ...pickCommonMutations([SET_MODEL]) } } diff --git a/src/views/Wallet.vue b/src/views/Wallet.vue index 4c9798f9..574a3980 100644 --- a/src/views/Wallet.vue +++ b/src/views/Wallet.vue @@ -1,6 +1,6 @@