/* global localStorage */ var React = require('react/addons') var Hq = require('../Services/Hq') var LinkedState = require('../Mixins/LinkedState') var UserStore = require('../Stores/UserStore') module.exports = React.createClass({ mixins: [LinkedState], propTypes: { team: React.PropTypes.shape({ name: React.PropTypes.string, profileName: React.PropTypes.string, email: React.PropTypes.string }) }, getInitialState: function () { var team = this.props.team return { currentTab: 'teamInfo', team: { name: team.name, profileName: team.profileName }, userSubmitStatus: null } }, selectTab: function (tabName) { return function () { this.setState({currentTab: tabName}) }.bind(this) }, saveUserInfo: function () { this.setState({ userSubmitStatus: 'sending' }, function () { Hq.updateUser(this.props.team.name, this.state.team) .then(function (res) { this.setState({userSubmitStatus: 'done'}, function () { UserStore.Actions.update(res.body) }) }.bind(this)) .catch(function (err) { console.error(err) this.setState({userSubmitStatus: 'error'}) }.bind(this)) }) }, render: function () { var content switch (this.state.currentTab) { case 'teamInfo': content = this.renderTeamInfoTab() break case 'members': content = this.renderMembersTab() break } return (