mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 18:56:22 +00:00
on Refactor... #3
This commit is contained in:
@@ -89,10 +89,25 @@ module.exports = React.createClass({
|
||||
},
|
||||
onPlanetChange: function (res) {
|
||||
if (this.state.planet == null) return
|
||||
console.log(res.data)
|
||||
|
||||
var code, note, articleIndex, articlesCount
|
||||
var planet, code, note, articleIndex, articlesCount
|
||||
switch (res.status) {
|
||||
case 'updated':
|
||||
planet = res.data
|
||||
if (this.state.planet.id === planet.id) {
|
||||
if (this.state.planet.name === planet.name) {
|
||||
this.setState({planet: planet})
|
||||
} else {
|
||||
this.transitionTo('planetHome', {userName: planet.userName, planetName: planet.name})
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'destroyed':
|
||||
planet = res.data
|
||||
if (this.state.planet.id === planet.id) {
|
||||
this.transitionTo('userHome', {userName: this.state.planet.userName})
|
||||
}
|
||||
break
|
||||
case 'codeUpdated':
|
||||
code = res.data
|
||||
if (code.PlanetId === this.state.planet.id) {
|
||||
|
||||
@@ -30,14 +30,15 @@ module.exports = React.createClass({
|
||||
}, function () {
|
||||
Hq.signup(this.state.user)
|
||||
.then(function (res) {
|
||||
console.log(res.body)
|
||||
localStorage.setItem('token', res.body.token)
|
||||
localStorage.setItem('currentUser', JSON.stringify(res.body.user))
|
||||
|
||||
this.transitionTo('userHome', {userName: res.body.user.name})
|
||||
}.bind(this))
|
||||
.catch(function (err) {
|
||||
console.error(err)
|
||||
var res = err.response
|
||||
console.error(res.body)
|
||||
if (err.status === 409) {
|
||||
// Confliction
|
||||
var emailConflicted = res.body.errors[0].path === 'email'
|
||||
@@ -90,12 +91,6 @@ module.exports = React.createClass({
|
||||
|
||||
<nav className='authNavigator text-center'><Link to='login'>Log In</Link> / <Link to='signup'>Sign Up</Link></nav>
|
||||
|
||||
<div className='socialControl'>
|
||||
<p>Connect with</p>
|
||||
<button className='facebookBtn'><i className='fa fa-facebook fa-fw'/></button>
|
||||
<button className='githubBtn'><i className='fa fa-github fa-fw'/></button>
|
||||
</div>
|
||||
|
||||
<div className='divider'>
|
||||
<hr/>
|
||||
<div className='dividerLabel'>or</div>
|
||||
|
||||
Reference in New Issue
Block a user