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.jsx56
1 files changed, 51 insertions, 5 deletions
diff --git a/client/components/App.jsx b/client/components/App.jsx
index f7cfa97..5a026b4 100644
--- a/client/components/App.jsx
+++ b/client/components/App.jsx
@@ -1,10 +1,56 @@
-import React from 'react';
+import React from 'react'
+import LoggedOutView from './LoggedOutView.jsx'
+import CalorieView from './CalorieView.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))
export default class App extends React.Component {
+ constructor() {
+ super()
+ this.state = {
+ ready: true,
+ loggedIn: false,
+ user: {},
+ }
+ client.authenticate()
+ .then(user => {
+ console.log(user)
+ this.setState({ ready: true, loggedIn: true, user: user })
+ })
+ .catch(error => {
+ this.setState({ ready: true })
+ console.error(error)
+ })
+ }
render() {
- return (
- <div style={{textAlign: 'center'}}>
- <h1>Hello World</h1>
- </div>);
+ if (this.state.ready) {
+ if (this.state.loggedIn) {
+ return (
+ <CalorieView client={client} />
+ )
+ }
+ else {
+ return (
+ <LoggedOutView client={client} />
+ )
+ }
+ }
+ else {
+ return (
+ <div>LOADING...</div>
+ )
+ }
}
}
+