aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/wallet-view.js
blob: 6f9269389e3cd219d12f17e6cc9542b6eb8144ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
const Component = require('react').Component
const connect = require('react-redux').connect
const h = require('react-hyperscript')
const inherits = require('util').inherits
const Identicon = require('./identicon')
const AccountDropdowns = require('./dropdowns/index.js').AccountDropdowns
const actions = require('../actions')
const BalanceComponent = require('./balance-component')
const selectors = require('../selectors')

module.exports = connect(mapStateToProps, mapDispatchToProps)(WalletView)

function mapStateToProps (state) {

  return {
    network: state.metamask.network,
    sidebarOpen: state.appState.sidebarOpen,
    identities: state.metamask.identities,
    accounts: state.metamask.accounts,
    selectedAddress: selectors.getSelectedAddress(state),
    selectedIdentity: selectors.getSelectedIdentity(state),
    selectedAccount: selectors.getSelectedAccount(state),
  }
}

function mapDispatchToProps (dispatch) {
  return {
    showSendPage: () => { dispatch(actions.showSendPage()) },
    hideSidebar: () => { dispatch(actions.hideSidebar()) },
  }
}

inherits(WalletView, Component)
function WalletView () {
  Component.call(this)
}

WalletView.prototype.render = function () {
  const { network, responsiveDisplayClassname, identities, selectedAddress, selectedAccount, accounts, selectedIdentity } = this.props
  // temporary logs + fake extra wallets
  console.log('walletview, selectedAccount:', selectedAccount)

  return h('div.wallet-view.flex-column' + (responsiveDisplayClassname || ''), {
    style: {},
  }, [

    // TODO: Separate component: wallet account details
    h('div.flex-column.wallet-view-account-details', {
      style: {},
    }, [

      h('div.flex-row.account-options-menu', {
        style: {
          position: 'relative',
        },
      }, [

        h(AccountDropdowns, {
          selected: selectedAddress,
          network,
          identities,
          useCssTransition: true,
          enableAccountOptions: true,
          dropdownWrapperStyle: {
            padding: '1px 15px',
            marginLeft: '-25px',
            position: 'absolute',
            width: '122%', // TODO, refactor all of this component out into media queries
          },
          menuItemStyles: {
            padding: '0px 0px',
            margin: '22px 0px',
          },
        }, []),

      ]),

      h('div.flex-column.flex-center', {
      }, [
        h('div', {
          style: {
            position: 'relative',
          },
        }, [
          h(AccountDropdowns, {
            accounts,
            style: {
              position: 'absolute',
              left: 'calc(50% + 28px + 5.5px)',
              top: '14px',
            },
            innerStyle: {
              padding: '2px 16px',
            },
            useCssTransition: true,
            selected: selectedAddress,
            network,
            identities,
            enableAccountsSelector: true,
          }, []),
        ]),

        h(Identicon, {
          diameter: 54,
          address: selectedAddress,
        }),

        h('span.account-name', {
          style: {},
        }, [
          selectedIdentity.name,
        ]),

      ]),
    ]),

    // 'Wallet' - Title
    // Not visible on mobile
    h('div.flex-column.wallet-view-title-wrapper', {}, [
      h('span.wallet-view-title', {}, [
        'Wallet',
      ]),
    ]),

    // Wallet Balances
    h('div.flex-column.wallet-balance-wrapper.wallet-balance-wrapper-active', {}, [

        h('div.wallet-balance', {}, [

          h(BalanceComponent, {
            balanceValue: selectedAccount.balance,
            style: {},
          }),

        ]),

    ]),

  ])
}

// TODO: Extra wallets, for dev testing. Remove when PRing to master.
// const extraWallet = h('div.flex-column.wallet-balance-wrapper', {}, [
//     h('div.wallet-balance', {}, [
//       h(BalanceComponent, {
//         balanceValue: selectedAccount.balance,
//         style: {},
//       }),
//     ]),
// ])