From 34691ba687be4adefb12864e49d5c5a357e1a74b Mon Sep 17 00:00:00 2001
From: Jules Laplace <jules@okfoc.us>
Date: Sun, 19 Mar 2017 04:00:24 +0100
Subject: create and update meals

---
 client/components/App.jsx | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

(limited to 'client/components/App.jsx')

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>
       )
     }
   }
-- 
cgit v1.2.3-70-g09d2

