OSDN Git Service

support multi-sign in new transaction page
[bytom/bytom-electron.git] / src / features / transactions / components / GeneratedTxHex / GeneratedTxHex.jsx
1 import React from 'react'
2 import { connect } from 'react-redux'
3 import { NotFound, PageContent, PageTitle } from 'features/shared/components'
4 import styles from './GeneratedTxHex.scss'
5 import { copyToClipboard } from 'utility/clipboard'
6
7 class Generated extends React.Component {
8   render() {
9     if (!this.props.hex) return <NotFound />
10
11     return (
12       <div>
13         <PageTitle title='Generated Transaction' />
14
15         <PageContent>
16           <div className={styles.main}>
17             <p>Use the following JSON string as the transaction to sign by another account:</p>
18
19             <button
20               className='btn btn-primary'
21               onClick={() => copyToClipboard(this.props.hex)}
22             >
23               Copy to clipboard
24             </button>
25
26             <pre className={styles.hex}>{this.props.hex}</pre>
27           </div>
28         </PageContent>
29       </div>
30     )
31   }
32 }
33
34 export default connect(
35   // mapStateToProps
36   (state, ownProps) => {
37     const generated = (state.transaction || {}).generated || []
38     const found = generated.find(i => i.id == ownProps.params.id)
39     if (found) return {hex: found.hex}
40     return {}
41   }
42 )(Generated)