aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pages/import-account/index.js
blob: 481ed6a4bd8d61da3dd28adbc2bd9004758ab2b1 (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
const Component = require('react').Component
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
import Select from 'react-select'

// Subviews
const JsonImportView = require('./json.js')
const PrivateKeyImportView = require('./private-key.js')

const PRIVATE_KEY_MENU_ITEM = 'Private Key'
const JSON_FILE_MENU_ITEM = 'JSON File'

class ImportAccount extends Component {
  constructor (props) {
    super(props)

    this.state = {
      current: PRIVATE_KEY_MENU_ITEM,
      menuItems: [ PRIVATE_KEY_MENU_ITEM, JSON_FILE_MENU_ITEM ],
    }
  }

  renderImportView () {
    const { current } = this.state

    switch (current) {
      case 'Private Key':
        return h(PrivateKeyImportView)
      case 'JSON File':
        return h(JsonImportView)
      default:
        return h(JsonImportView)
    }
  }

  render () {
    const { history } = this.props
    const { current, menuItems } = this.state

    return (
      h('div.flex-center', {
        style: {
          flexDirection: 'column',
          marginTop: '32px',
        },
      }, [
        h('.section-title.flex-row.flex-center', [
          h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
            onClick: history.goBack,
          }),
          h('h2.page-subtitle', 'Import Accounts'),
        ]),
        h('div', {
          style: {
            padding: '10px 0',
            width: '260px',
            color: 'rgb(174, 174, 174)',
          },
        }, [

          h('h3', { style: { padding: '3px' } }, 'SELECT TYPE'),

          h('style', `
            .has-value.Select--single > .Select-control .Select-value .Select-value-label, .Select-value-label {
              color: rgb(174,174,174);
            }
          `),

          h(Select, {
            name: 'import-type-select',
            clearable: false,
            value: current,
            options: menuItems.map(type => {
              return {
                value: type,
                label: type,
              }
            }),
            onChange: opt => {
              this.setState({ current: opt.value })
            },
          }),
        ]),

        this.renderImportView(),
      ])
    )
  }
}

ImportAccount.propTypes = {
  history: PropTypes.object,
}

module.exports = ImportAccount