2015-08-31 16:36:24 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import Router from 'react-router';
|
|
|
|
|
2015-09-18 09:46:37 +02:00
|
|
|
import UserStore from '../../stores/user_store';
|
|
|
|
import UserActions from '../../actions/user_actions';
|
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
import AccountSettings from './account_settings';
|
|
|
|
import BitcoinWalletSettings from './bitcoin_wallet_settings';
|
|
|
|
import ContractSettings from './contract_settings';
|
|
|
|
import APISettings from './api_settings';
|
|
|
|
|
|
|
|
|
|
|
|
let SettingsContainer = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
|
|
React.PropTypes.element])
|
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [Router.Navigation],
|
|
|
|
|
2015-09-18 09:46:37 +02:00
|
|
|
getInitialState() {
|
|
|
|
return UserStore.getState();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
UserStore.listen(this.onChange);
|
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
UserStore.unlisten(this.onChange);
|
|
|
|
},
|
|
|
|
|
|
|
|
loadUser(){
|
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
},
|
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
render() {
|
2015-09-21 10:32:35 +02:00
|
|
|
if (this.state.currentUser && this.state.currentUser.username) {
|
|
|
|
return (
|
|
|
|
<div className="settings-container">
|
|
|
|
<AccountSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/>
|
|
|
|
{this.props.children}
|
|
|
|
<APISettings />
|
|
|
|
<BitcoinWalletSettings />
|
|
|
|
<ContractSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
2015-08-31 16:36:24 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default SettingsContainer;
|