-
Notifications
You must be signed in to change notification settings - Fork 295
/
SecuringPasswordDialog.tsx
132 lines (118 loc) · 4.47 KB
/
SecuringPasswordDialog.tsx
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
// @flow
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import classnames from 'classnames';
import { defineMessages, intlShape } from 'react-intl';
import { Checkbox } from 'react-polymorph/lib/components/Checkbox';
import { CheckboxSkin } from 'react-polymorph/lib/skins/simple/CheckboxSkin';
import Dialog from '../../widgets/Dialog';
import DialogCloseButton from '../../widgets/DialogCloseButton';
import paperWalletImage from '../../../assets/images/paper-wallet-certificate/certificate.png';
import globalMessages from '../../../i18n/global-messages';
import styles from './SecuringPasswordDialog.scss';
import { PAPER_WALLET_WRITTEN_WORDS_COUNT } from '../../../config/cryptoConfig';
const messages = defineMessages({
headline: {
id: 'paper.wallet.create.certificate.securingPassword.dialog.headline',
defaultMessage: '!!!Complete your certificate',
description:
'Headline for the "Paper wallet create certificate securing password dialog".',
},
infoLabel1: {
id: 'paper.wallet.create.certificate.securingPassword.dialog.infoLabel1',
defaultMessage: `!!!To complete your paper wallet certificate you will need to
write the remaining {paperWalletWrittenWordsCount} words of your paper wallet recovery
phrase on your certificate.`,
description:
'"Paper wallet create certificate securing password dialog" first info label.',
},
infoLabel2: {
id: 'paper.wallet.create.certificate.securingPassword.dialog.infoLabel2',
defaultMessage:
'!!!The password can optionally be written on the certificate or kept securely in other location. Here is the placeholder on the certificate intended for your password.',
description: 'You may write the remaining words here:',
},
securingPasswordConfirmation: {
id:
'paper.wallet.create.certificate.securingPassword.dialog.securingPasswordConfirmation',
defaultMessage:
'!!!I have written the remaining {paperWalletWrittenWordsCount} words on the certificate.',
description:
'"Paper wallet create certificate securing password dialog" secure password confirmation.',
},
});
type State = {
securePasswordConfirmed: boolean,
};
type Props = {
additionalMnemonics: string,
onContinue: Function,
onClose: Function,
};
@observer
export default class SecuringPasswordDialog extends Component<Props, State> {
static contextTypes = {
intl: intlShape.isRequired,
};
state = {
securePasswordConfirmed: false,
};
onSecurePasswordConfirmation = () => {
this.setState((prevState) => ({
securePasswordConfirmed: !prevState.securePasswordConfirmed,
}));
};
render() {
const { intl } = this.context;
const { securePasswordConfirmed } = this.state;
const { additionalMnemonics, onContinue, onClose } = this.props;
const dialogClasses = classnames([
styles.component,
'SecuringPasswordDialog',
]);
const actions = [
{
className: 'continueButton',
label: intl.formatMessage(globalMessages.dialogButtonContinueLabel),
primary: true,
disabled: !securePasswordConfirmed,
onClick: onContinue,
},
];
return (
<Dialog
className={dialogClasses}
title={intl.formatMessage(messages.headline)}
actions={actions}
onClose={onClose}
closeButton={<DialogCloseButton />}
>
<div className={styles.securingPasswordContentWrapper}>
<div className={styles.content}>
<p className={styles.infoLabel}>
{intl.formatMessage(messages.infoLabel1, {
paperWalletWrittenWordsCount: PAPER_WALLET_WRITTEN_WORDS_COUNT,
})}
</p>
<div className={styles.recoveryPhrase}>{additionalMnemonics}</div>
<p className={styles.infoLabel}>
{intl.formatMessage(messages.infoLabel2)}
</p>
<div className={styles.paperWalletImageWrapper}>
<img src={paperWalletImage} role="presentation" />
</div>
<Checkbox
className={styles.securingPasswordConfirmation}
label={intl.formatMessage(messages.securingPasswordConfirmation, {
paperWalletWrittenWordsCount: PAPER_WALLET_WRITTEN_WORDS_COUNT,
})}
onChange={this.onSecurePasswordConfirmation}
checked={securePasswordConfirmed}
skin={CheckboxSkin}
/>
</div>
</div>
</Dialog>
);
}
}