-
Notifications
You must be signed in to change notification settings - Fork 312
/
ShowQrForExportModal.jsx
93 lines (86 loc) · 2.56 KB
/
ShowQrForExportModal.jsx
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
// @flow
import React, { Component } from 'react'
import { FormattedMessage } from 'react-intl'
import FullHeightPanel from '../../Panel/FullHeightPanel'
import BaseModal from '../BaseModal'
import styles from './ShowQrForExportModal.scss'
import CloseButton from '../../CloseButton'
import Qr from '../../../assets/icons/grid.svg'
import withCopyCanvasToClipboard from '../../../hocs/withCopyCanvasToClipboard'
import Button from '../../Button'
type Props = {
hideModal: Function,
address: string,
encryptedWIF: string,
handleCreateCanvas: (?HTMLCanvasElement, string) => any,
IS_NEP2_EXPORT: string,
IS_ADDRESS: string,
}
class ShowQrForExportModal extends Component<Props> {
targetCanvas: ?HTMLCanvasElement
componentDidMount() {
const { address, encryptedWIF, IS_NEP2_EXPORT, IS_ADDRESS } = this.props
let importString
if (IS_NEP2_EXPORT) {
importString = `neon://import_key/${encryptedWIF}`
}
if (IS_ADDRESS) {
importString = `neon://import_address/${address}`
}
setTimeout(() => {
this.props.handleCreateCanvas(this.targetCanvas, importString)
}, 100)
}
render() {
const { hideModal, IS_NEP2_EXPORT } = this.props
return (
<BaseModal
hideModal={hideModal}
shouldRenderHeader={false}
style={{
content: {
width: '730px',
height: '100%',
},
}}
>
<FullHeightPanel
containerClassName={styles.releaseNotesContainer}
renderInstructions={false}
renderHeaderIcon={() => <Qr />}
headerText="QR Export"
renderCloseButton={() => (
<div className={styles.closeButton} onClick={() => hideModal()}>
<CloseButton renderWithoutLink />
</div>
)}
>
<div>
<br />
Open Neon on your mobile device and tap "Scan QR Code" to import
your account
</div>
<div className={styles.qr}>
<label>
{' '}
<FormattedMessage
id={IS_NEP2_EXPORT ? 'encryptedKeyLabel' : 'addressLabel'}
/>{' '}
</label>
<canvas
ref={node => {
this.targetCanvas = node
}}
/>
</div>
<div className={styles.buttonContainer}>
<Button primary onClick={hideModal}>
Close
</Button>
</div>
</FullHeightPanel>
</BaseModal>
)
}
}
export default withCopyCanvasToClipboard(ShowQrForExportModal)