summaryrefslogtreecommitdiff
path: root/client/components/App.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/App.jsx')
-rw-r--r--client/components/App.jsx36
1 files changed, 17 insertions, 19 deletions
diff --git a/client/components/App.jsx b/client/components/App.jsx
index 5a026b4..99c2c11 100644
--- a/client/components/App.jsx
+++ b/client/components/App.jsx
@@ -1,54 +1,52 @@
import React from 'react'
import LoggedOutView from './LoggedOutView.jsx'
-import CalorieView from './CalorieView.jsx'
+import MealView from './MealView.jsx'
-import feathers from 'feathers/client'
-import feathersHooks from 'feathers-hooks'
-import feathersRest from 'feathers-rest/client'
-import feathersAuthentication from 'feathers-authentication/client'
-import superagent from 'superagent'
-
-const rest = feathersRest(window.location.origin)
-
-const client = feathers()
- .configure(feathersHooks())
- .configure(feathersAuthentication({ storage: localStorage }))
- .configure(rest.superagent(superagent))
+import client from '../client'
export default class App extends React.Component {
constructor() {
super()
this.state = {
- ready: true,
+ ready: false,
loggedIn: false,
user: {},
}
client.authenticate()
.then(user => {
- console.log(user)
- this.setState({ ready: true, loggedIn: true, user: user })
+ this.setState({
+ ready: true,
+ loggedIn: true,
+ user: user.data
+ })
})
.catch(error => {
this.setState({ ready: true })
console.error(error)
})
}
+ logOut() {
+ this.setState({
+ user: null,
+ loggedIn: false,
+ })
+ }
render() {
if (this.state.ready) {
if (this.state.loggedIn) {
return (
- <CalorieView client={client} />
+ <MealView user={this.state.user} />
)
}
else {
return (
- <LoggedOutView client={client} />
+ <LoggedOutView />
)
}
}
else {
return (
- <div>LOADING...</div>
+ <div>Loading...</div>
)
}
}