/* global localStorage */ var React = require('react/addons') var request = require('superagent') var Catalyst = require('../Mixins/Catalyst') var AuthActions = require('../Actions/AuthActions') var apiUrl = 'http://localhost:8000/' module.exports = React.createClass({ mixins: [Catalyst.LinkedStateMixin], propTypes: { close: React.PropTypes.func, currentUser: React.PropTypes.object }, getInitialState: function () { return { currentTab: 'profile', userName: this.props.currentUser.name, email: this.props.currentUser.email, currentPassword: '', newPassword: '', confirmation: '', contactTitle: '', contactContent: '' } }, activeProfile: function () { this.setState({currentTab: 'profile'}) }, activeContact: function () { this.setState({currentTab: 'contact'}) }, activeInfo: function () { this.setState({currentTab: 'info'}) }, activeLogout: function () { this.setState({currentTab: 'logout'}) }, saveProfile: function () { AuthActions.updateProfile({ name: this.state.userName, email: this.state.email }) }, savePassword: function () { if (this.state.newPassword === this.state.confirmation) { request .put(apiUrl + 'auth/password') .set({ Authorization: 'Bearer ' + localStorage.getItem('token') }) .send({ currentPassword: this.state.currentPassword, newPassword: this.state.newPassword }) .end(function (err, res) { this.setState({ currentPassword: '', newPassword: '', confirmation: '' }) if (err) { console.error(err) return } }.bind(this)) } }, sendEmail: function () { }, logOut: function () { AuthActions.logout() }, interceptClick: function (e) { e.stopPropagation() }, render: function () { var content if (this.state.currentTab === 'profile') { content = (
Let us know your opinion about CodeXen.
Your feedback might be used to improvement of CodeXen.
Are you sure to logout?
