From 6ae0c07daeea0e03c832b3aa0f838778627431d8 Mon Sep 17 00:00:00 2001
From: Jules Laplace <jules@okfoc.us>
Date: Mon, 20 Mar 2017 04:48:32 +0100
Subject: view app as a different user

---
 client/components/LoggedInView.jsx | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

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

diff --git a/client/components/LoggedInView.jsx b/client/components/LoggedInView.jsx
index 3fa3e8b..ecf1356 100644
--- a/client/components/LoggedInView.jsx
+++ b/client/components/LoggedInView.jsx
@@ -11,26 +11,44 @@ export default class LoggedInView extends React.Component {
     super()
     this.state = {
       user: Object.assign({}, props.user),
+      meals: [],
       mode: 'meals',
     }
     this.updateUser = this.updateUser.bind(this)
+    this.updateMeals = this.updateMeals.bind(this)
     this.toggleMode = this.toggleMode.bind(this)
   }
   toggleMode(){
-    this.state.mode = this.state.mode == 'meals' ? 'users' : 'meals'
+    this.setState({ mode: this.state.mode == 'meals' ? 'users' : 'meals' })
   }
   updateUser(user) {
     this.setState({
-      user: user
+      user: user,
+      mode: 'meals',
+    })
+  }
+  updateMeals(user) {
+    this.setState({
+      meals: meals,
     })
   }
   render() {
     let activity = null
     if (this.state.mode == 'meals') {
-      activity = (<MealList user={this.state.user} currentUser={this.props.user} />)
+      activity = (
+        <MealList user={this.state.user}
+          currentUser={this.props.user}
+          onUpdate={this.updateMeals}
+        />
+      )
     }
     else {
-      activity = (<UserList user={this.state.user} currentUser={this.props.user} updateUser={this.updateUser} />)
+      activity = (
+        <UserList user={this.state.user}
+          currentUser={this.props.user}
+          updateUser={this.updateUser}
+        />
+      )
     }
     return (
       <div>
-- 
cgit v1.2.3-70-g09d2

