import React from 'react' import client from '../client' export default class Menu extends React.Component { constructor() { super() this.setGoal = this.setGoal.bind(this) this.logout = this.logout.bind(this) } setGoal() { const goal = Math.abs(parseInt(prompt('Please enter your calorie goal', this.props.user.goal))) if (goal) { client.service('users').patch(this.props.user.id, { goal: goal, token: client.get('token'), }).then((user) => { this.props.updateUser(user) }) } } logout() { client.logout().then(() => { window.location.reload() }) } render() { const user = this.props.user const currentUser = this.props.currentUser const observing = user.id !== currentUser.id const items = [] if (observing) { items.push(
  • Viewing {user.email}
  • ) } else { items.push(
  • Hello {currentUser.email}
  • ) } items.push(
  • Goal: {user.goal} cal
  • ) switch (currentUser.role) { case 'admin': // if (this.props.user.id !== this.props.currentUser.id) { // items.push(
  • Stop viewing
  • ) // } items.push(
  • Users
  • ) items.push(
  • Meals
  • ) break case 'manager': items.push(
  • Users
  • ) items.push(
  • Meals
  • ) case 'user': break } items.push(
  • Logout
  • ) return (
    ) } }