-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from swaponline/account-list
account list issue-#6
- Loading branch information
Showing
6 changed files
with
223 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<div> | ||
<v-toolbar class="header-list" color="purple"> | ||
<v-btn class="header-list__button ml-1" icon @click="openAccountMenu"> | ||
<v-img :src="photo" width="48" height="48" class="rounded-circle" position="center top" /> | ||
</v-btn> | ||
<v-spacer></v-spacer> | ||
<v-toolbar-items class="header-list__summ align-center"> | ||
<span>{{ balance }}</span> | ||
</v-toolbar-items> | ||
</v-toolbar> | ||
<div | ||
class="header-list__extension" | ||
:style="openMenu ? styleParams : ''" | ||
:class="{ | ||
'header-list__extension--visible': openMenu | ||
}" | ||
> | ||
<v-list class="py-0"> | ||
<v-list-item v-for="account in accounts" :key="account.id" @click="setAccount(account.id)"> | ||
{{ account.name }} | ||
</v-list-item> | ||
</v-list> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapActions } from 'vuex' | ||
import { MODULE_NAME as WALLETS_MODULE, SET_ACCOUNT_ID } from '@/store/modules/Wallets' | ||
export default { | ||
name: 'HeaderList', | ||
data() { | ||
return { | ||
openMenu: false | ||
} | ||
}, | ||
computed: { | ||
photo() { | ||
// eslint-disable-next-line vue/max-len | ||
return `https://sun9-60.userapi.com/impg/zCF4saFPwlwi0PtC41GIQ1WP30Khy-thQ9FtuA/b6bn4u-Y9D4.jpg?size=646x1148&quality=96&proxy=1&sign=b1ff76233f1ee088d886dd165748e481&type=album` | ||
}, | ||
balance() { | ||
return this.$store.getters.walletsSumm | ||
}, | ||
styleParams() { | ||
return `max-height: ${48 * this.accounts.length}px;` | ||
}, | ||
accounts() { | ||
return this.$store.state[WALLETS_MODULE].list | ||
} | ||
}, | ||
methods: { | ||
...mapActions({ | ||
actionSetAccount: SET_ACCOUNT_ID | ||
}), | ||
openAccountMenu() { | ||
this.openMenu = !this.openMenu | ||
}, | ||
setAccount(id) { | ||
this.actionSetAccount(id) | ||
this.openMenu = false | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
.header-list { | ||
font-size: 18px; | ||
max-height: 64px; | ||
&__summ { | ||
color: $--white; | ||
font-weight: 500; | ||
} | ||
&__extension { | ||
overflow: hidden; | ||
max-height: 0; | ||
transition: 0.5s; | ||
background: yellow; | ||
&--visible { | ||
height: auto; | ||
// @include tablet { | ||
// min-height: calc(100vh - 152px) !important; | ||
// } | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.