|
|
@ -3,11 +3,11 @@ |
|
|
|
import React, { PureComponent } from 'react' |
|
|
|
import { connect } from 'react-redux' |
|
|
|
|
|
|
|
// import type { Settings, T } from 'types/common'
|
|
|
|
import type { T } from 'types/common' |
|
|
|
import type { Settings, T } from 'types/common' |
|
|
|
|
|
|
|
import { unlock } from 'reducers/application' |
|
|
|
|
|
|
|
import Input from 'components/base/Input' |
|
|
|
import IconUser from 'icons/User' |
|
|
|
|
|
|
|
import { |
|
|
@ -19,22 +19,37 @@ import { |
|
|
|
|
|
|
|
type Props = { |
|
|
|
t: T, |
|
|
|
// settings: Settings,
|
|
|
|
// onSaveSettings: Function,
|
|
|
|
settings: Settings, |
|
|
|
saveSettings: Function, |
|
|
|
// unlock: Function,
|
|
|
|
} |
|
|
|
|
|
|
|
type State = {} |
|
|
|
|
|
|
|
const mapStateToProps = state => ({ |
|
|
|
username: state.settings, |
|
|
|
}) |
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
unlock, |
|
|
|
} |
|
|
|
|
|
|
|
class TabProfile extends PureComponent<Props, State> { |
|
|
|
state = {} |
|
|
|
state = { |
|
|
|
username: this.props.settings.username, |
|
|
|
} |
|
|
|
|
|
|
|
handleChangeUsername = username => { |
|
|
|
const { saveSettings } = this.props |
|
|
|
this.setState({ username }) |
|
|
|
window.requestIdleCallback(() => { |
|
|
|
saveSettings({ username: username.trim() || 'Anonymous' }) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
render() { |
|
|
|
const { t } = this.props |
|
|
|
const { username } = this.state |
|
|
|
|
|
|
|
return ( |
|
|
|
<Section> |
|
|
@ -45,7 +60,12 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
|
/> |
|
|
|
<Body> |
|
|
|
<Row title={t('settings:profile.username')} desc={t('settings:profile.usernameDesc')}> |
|
|
|
{'-'} |
|
|
|
<Input |
|
|
|
small |
|
|
|
placeholder={t('settings:profile.username')} |
|
|
|
onChange={this.handleChangeUsername} |
|
|
|
value={username} |
|
|
|
/> |
|
|
|
</Row> |
|
|
|
<Row title={t('settings:profile.password')} desc={t('settings:profile.passwordDesc')}> |
|
|
|
{'-'} |
|
|
@ -65,4 +85,4 @@ class TabProfile extends PureComponent<Props, State> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export default connect(null, mapDispatchToProps)(TabProfile) |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(TabProfile) |
|
|
|