From 2e4aaf7345b1a2444f9eeaa1bd1427183b05f75a Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Fri, 24 Jul 2015 15:13:04 +0900 Subject: [PATCH] add PersonalSettingModal --- browser/main/Actions/AuthActions.js | 3 +- .../main/Components/PersonalSettingModal.jsx | 171 ++++++++++++++++++ .../main/Components/PlanetSettingModal.jsx | 10 +- browser/main/Components/UserNavigator.jsx | 18 +- browser/main/Containers/LoginContainer.jsx | 15 -- browser/main/Containers/MainContainer.jsx | 25 +++ browser/main/Containers/PlanetContainer.jsx | 23 ++- browser/main/Containers/RegisterContainer.jsx | 15 -- browser/main/Containers/UserContainer.jsx | 83 ++++++++- browser/main/Stores/AuthStore.js | 44 ++++- browser/main/index.jsx | 4 +- .../styles/main/containers/UserContainer.styl | 36 +++- browser/styles/mixins/btnStyle.styl | 13 +- browser/styles/shared/modal.styl | 67 ++++++- 14 files changed, 460 insertions(+), 67 deletions(-) create mode 100644 browser/main/Components/PersonalSettingModal.jsx diff --git a/browser/main/Actions/AuthActions.js b/browser/main/Actions/AuthActions.js index f0b84f05..a9c437fe 100644 --- a/browser/main/Actions/AuthActions.js +++ b/browser/main/Actions/AuthActions.js @@ -3,5 +3,6 @@ var Reflux = require('reflux') module.exports = Reflux.createActions([ 'login', 'register', - 'logout' + 'logout', + 'updateProfile' ]) diff --git a/browser/main/Components/PersonalSettingModal.jsx b/browser/main/Components/PersonalSettingModal.jsx new file mode 100644 index 00000000..af73063a --- /dev/null +++ b/browser/main/Components/PersonalSettingModal.jsx @@ -0,0 +1,171 @@ +/* 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 = ( +
+
+
+ + +
+
+ + +
+
+ +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ ) + } else if (this.state.currentTab === 'contact') { + content = ( +
+

+ Let us know your opinion about CodeXen.
+ Your feedback might be used to improvement of CodeXen. +

+ +