// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var SettingItemMin = require('./setting_item_min.jsx'); var SettingItemMax = require('./setting_item_max.jsx'); var Client = require('../utils/client.jsx'); var AsyncClient = require('../utils/async_client.jsx'); export default class FeatureTab extends React.Component { constructor(props) { super(props); this.submitValetFeature = this.submitValetFeature.bind(this); this.handleValetRadio = this.handleValetRadio.bind(this); this.onUpdateSection = this.onUpdateSection.bind(this); this.state = {}; var team = this.props.team; if (team && team.allow_valet) { this.state.allowValet = 'true'; } else { this.state.allowValet = 'false'; } } componentWillReceiveProps(newProps) { var team = newProps.team; var allowValet = 'false'; if (team && team.allow_valet) { allowValet = 'true'; } this.setState({allowValet: allowValet}); } submitValetFeature() { var data = {}; data.allow_valet = this.state.allowValet; Client.updateValetFeature(data, function success() { this.props.updateSection(''); AsyncClient.getMyTeam(); }.bind(this), function fail(err) { var state = this.getInitialState(); state.serverError = err; this.setState(state); }.bind(this) ); } handleValetRadio(val) { this.setState({allowValet: val}); React.findDOMNode(this.refs.wrapper).focus(); } onUpdateSection(e) { e.preventDefault(); if (this.props.activeSection === 'valet') { this.props.updateSection(''); } else { this.props.updateSection('valet'); } } render() { var clientError = null; var serverError = null; if (this.state.clientError) { clientError = this.state.clientError; } if (this.state.serverError) { serverError = this.state.serverError; } var valetSection; if (this.props.activeSection === 'valet') { var valetActive = [false, false]; if (this.state.allowValet === 'false') { valetActive[1] = true; } else { valetActive[0] = true; } let inputs = []; inputs.push(