// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var ChannelStore = require('../stores/channel_store.jsx'); var UserStore = require('../stores/user_store.jsx'); var Client = require('../utils/client.jsx'); var AsyncClient = require('../utils/async_client.jsx'); var MemberListTeamItem = React.createClass({ handleMakeMember: function() { var data = {}; data["user_id"] = this.props.user.id; data["new_roles"] = ""; Client.updateRoles(data, function(data) { AsyncClient.getProfiles(); }.bind(this), function(err) { this.setState({ server_error: err.message }); }.bind(this) ); }, handleMakeActive: function() { Client.updateActive(this.props.user.id, true, function(data) { AsyncClient.getProfiles(); }.bind(this), function(err) { this.setState({ server_error: err.message }); }.bind(this) ); }, handleMakeNotActive: function() { Client.updateActive(this.props.user.id, false, function(data) { AsyncClient.getProfiles(); }.bind(this), function(err) { this.setState({ server_error: err.message }); }.bind(this) ); }, handleMakeAdmin: function() { var data = {}; data["user_id"] = this.props.user.id; data["new_roles"] = "admin"; Client.updateRoles(data, function(data) { AsyncClient.getProfiles(); }.bind(this), function(err) { this.setState({ server_error: err.message }); }.bind(this) ); }, getInitialState: function() { return {}; }, render: function() { var server_error = this.state.server_error ?
: null; var user = this.props.user; var currentRoles = "Member"; var timestamp = UserStore.getCurrentUser().update_at; if (user.roles.length > 0) { currentRoles = user.roles.charAt(0).toUpperCase() + user.roles.slice(1); } var email = user.email.length > 0 ? user.email : ""; var showMakeMember = user.roles == "admin"; var showMakeAdmin = user.roles == ""; var showMakeActive = false; var showMakeNotActive = true; if (user.delete_at > 0) { currentRoles = "Inactive"; showMakeMember = false; showMakeAdmin = false; showMakeActive = true; showMakeNotActive = false; } return (