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/Menu.jsx | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

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

diff --git a/client/components/Menu.jsx b/client/components/Menu.jsx
index d53803d..471336e 100644
--- a/client/components/Menu.jsx
+++ b/client/components/Menu.jsx
@@ -27,10 +27,17 @@ export default class Menu extends React.Component {
   }
   render() {
     const user = this.props.user
+    const currentUser = this.props.currentUser
+    const observing = user.id !== currentUser.id
     const items = []
-    items.push( <li key='hello'>Hello {user.email}</li> )
-    items.push( <li key='goal' onClick={this.setGoal}><a href='#'>Goal</a>: {user.goal}</li> )
-    switch (user.role) {
+    if (observing) {
+      items.push( <li key='observing'><i>Viewing</i> {user.email}</li> )
+    }
+    else {
+      items.push( <li key='hello'>Hello {currentUser.email}</li> )
+    }
+    items.push( <li key='goal' onMouseDown={this.setGoal}><a href='#'>Goal</a>: {user.goal} cal</li> )
+    switch (currentUser.role) {
       case 'admin':
         if (this.props.user.id !== this.props.currentUser.id) {
           items.push( <li key='resetUser'><a href='#' onClick={this.resetUser}>Reset User</a></li> )
-- 
cgit v1.2.3-70-g09d2

