-
Notifications
You must be signed in to change notification settings - Fork 188
/
index.js
106 lines (87 loc) · 2.69 KB
/
index.js
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
/**
*
* TokenChooser
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Modal, Button } from 'antd';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { compose } from 'redux';
// import injectSaga from 'utils/injectSaga';
import injectReducer from 'utils/injectReducer';
import TokenChooserList from 'components/TokenChooserList';
import { makeSelectNetworkName } from 'containers/Header/selectors';
import { makeSelectChosenTokens } from './selectors';
import { toggleToken, confirmNewTokenInfo } from './actions';
// import { makeSelectTokenChooser } from './selectors';
import reducer from './reducer';
// import saga from './saga';
import TokenSelection from './token-lists';
function TokenChooser(props) {
const {
isShowTokenChooser,
onHideTokenChooser,
chosenTokens,
onToggleToken,
onConfirmNewTokenInfo,
networkName,
} = props;
const TokensForNetwork = TokenSelection[networkName];
return (
<div style={{ maxWidth: '600px', margin: 'auto' }}>
<Modal
visible={isShowTokenChooser}
title={`Select Tokens - ${networkName}`}
onOk={onHideTokenChooser}
onCancel={onHideTokenChooser}
footer={null}
>
<TokenChooserList
tokenList={TokensForNetwork}
chosenTokens={chosenTokens}
onTokenToggle={onToggleToken}
/>
<br />
<Button type="primary" onClick={() => onConfirmNewTokenInfo(chosenTokens, networkName)} disabled={false} >
Update
</Button>{' '}
<Button onClick={() => onConfirmNewTokenInfo()} disabled={false} >
Remove Tokens
</Button>
</Modal>
</div>
);
}
TokenChooser.propTypes = {
// dispatch: PropTypes.func.isRequired,
isShowTokenChooser: PropTypes.bool,
onHideTokenChooser: PropTypes.func,
chosenTokens: PropTypes.object,
onToggleToken: PropTypes.func,
onConfirmNewTokenInfo: PropTypes.func,
networkName: PropTypes.string,
};
const mapStateToProps = createStructuredSelector({
chosenTokens: makeSelectChosenTokens(),
networkName: makeSelectNetworkName(),
});
function mapDispatchToProps(dispatch) {
return {
onToggleToken: (symbol, toggle) => {
dispatch(toggleToken(symbol, toggle));
},
onConfirmNewTokenInfo: (chosenTokens, networkName) => {
dispatch(confirmNewTokenInfo(chosenTokens, networkName));
},
};
}
const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withReducer = injectReducer({ key: 'tokenchooser', reducer });
// const withSaga = injectSaga({ key: 'tokenchooser', saga });
export default compose(
withReducer,
// withSaga,
withConnect,
)(TokenChooser);