-
Notifications
You must be signed in to change notification settings - Fork 97
/
setting.js
179 lines (171 loc) · 5.89 KB
/
setting.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import React from 'react';
import { Link } from 'react-router-dom';
// import ReactSwipe from 'react-swipe';
import Checkbox from '../toolbox/sliderCheckbox';
import styles from './setting.css';
import i18n from '../../i18n';
import accountConfig from '../../constants/account';
import breakpoints from './../../constants/breakpoints';
import settingsConst from './../../constants/settings';
// TODO: will be re-enabled when the functionality is updated
import routes from '../../constants/routes';
import { FontIcon } from '../fontIcon';
import Box from '../box';
// import languageSwitcherTheme from './languageSwitcher.css';
class Setting extends React.Component {
constructor() {
super();
this.state = {
activeSlide: 0,
currencies: settingsConst.currencies,
};
}
changeSlide(i) {
this.reactSwipe.slide(i);
this.setState({
activeSlide: i,
});
}
// changeLanguage(e) {//eslint-disable-line
// if (e.checked) {
// i18n.changeLanguage('de');
// } else {
// i18n.changeLanguage('en');
// }
// }
toggleAutoLog(state) {
const {
account, settings, settingsUpdated, accountUpdated,
} = this.props;
if (state && account.passphrase) {
const date = Date.now() + accountConfig.lockDuration;
accountUpdated({ expireTime: date });
}
settingsUpdated({ autoLog: !settings.autoLog });
}
render() {
this.language = (i18n.language === 'de');
const {
t, settings, settingsUpdated,
hasSecondPassphrase,
} = this.props;
const allowAuthClass = !this.props.isAuthenticated ? styles.disable : '';
const showOnboardingSetting = window.innerWidth > breakpoints.m;
const activeCurrency = settings.currency || settingsConst.currencies[0];
return (<Box className={styles.wrapper}>
<aside>
<header>
<h4>{t('Settings')}</h4>
<p>{t('Set up Lisk Hub and your account.')}</p>
</header>
{showOnboardingSetting
? <div className={`${styles.item} onBoarding`}>
<label>{t('Start the onboarding')}</label>
<button className={`${styles.settingsButton} onboarding-setting`} onClick={() => {
this.props.settingsUpdated({ onBoarding: true });
}
}>
{t('Start')}
<FontIcon>arrow-right</FontIcon>
</button>
</div>
: null
}
</aside>
<section>
<h4 className={`${allowAuthClass}`}>{t('Security')}</h4>
<div className={styles.item}>
<label className={`${allowAuthClass}`}>{t('2nd passphrase (Fee: 5 LSK)')}</label>
{!hasSecondPassphrase ?
<Link
className={`register-second-passphrase ${styles.secondPassphrase} ${allowAuthClass}`}
to={`${routes.secondPassphrase.path}`}>
{t('Register')}
<FontIcon>arrow-right</FontIcon>
</Link> :
<span
className={`register-second-passphrase ${styles.secondPassphraseEnabled}`}>
{t('Registered')}
<FontIcon>checkmark</FontIcon>
</span>
}
</div>
<div className={styles.item}>
<label className={`${allowAuthClass}`}>{t('Auto-Lock')}</label>
<Checkbox
theme={styles}
disabled={!this.props.isAuthenticated}
className={`${styles.smallSlider} autoLog ${allowAuthClass}`}
onChange={() => this.toggleAutoLog(!settings.autoLog)}
input={{
value: true,
checked: settings.autoLog,
}}/>
</div>
<h4>{t('Advanced features')}</h4>
<div className={styles.item}>
<label>{t('Switch networks (Main-/Testnet, Custom)')}</label>
<Checkbox
theme={styles}
className={`${styles.smallSlider} showNetwork`}
onChange={() => settingsUpdated({ showNetwork: !settings.showNetwork })}
input={{
value: false,
checked: settings.showNetwork,
}}/>
</div>
<div className={styles.item}>
<label className={`${allowAuthClass}`}>{t('Delegate features')}</label>
<Checkbox
theme={styles}
disabled={!this.props.isAuthenticated}
className={`${styles.smallSlider} advancedMode ${allowAuthClass}`}
onChange={() => settingsUpdated({ advancedMode: !settings.advancedMode })}
input={{
value: true,
checked: settings.advancedMode,
}}/>
</div>
<h4>{t('Local')}</h4>
<div className={styles.item}>
<label>{t('Currency')}</label>
<ul className={styles.currencyList}>
{this.state.currencies.map(currency => (
<li
key={`currency-${currency}`}
className={`currency ${currency === activeCurrency ? styles.active : ''}`}
onClick={() => settingsUpdated({ currency })}>
{currency}
</li>
))}
</ul>
</div>
{/* TODO: will be re-enabled when the functionality is updated
{/* TODO: will be re-enabled when the functionality is updated
<div>
<Checkbox
theme={languageSwitcherTheme}
className={`${styles.smallSlider} language-switcher`}
onChange={this.changeLanguage.bind(this)}
textAsIcon={true}
icons={{
unchecked: 'EN',
checked: 'DE',
goal: 'DE',
begin: 'EN',
}}
input={{
value: 'true',
checked: this.language,
}}/>
<article>
<h5>{t('Language')}</h5>
<p>{t('Currently we speaking english and german.')}</p>
</article>
</div>
*/}
</section>
</Box>);
}
}
export default Setting;