import React from 'react'
import ModalDialog from './ModalDialog.jsx'
import UserList from './UserList.jsx'
import MealList from './MealList.jsx'
import client from '../client'
export default class LoggedInView extends React.Component {
constructor(props) {
super()
this.state = {
user: Object.assign({}, props.user),
mode: 'meals',
}
this.updateUser = this.updateUser.bind(this)
this.toggleMode = this.toggleMode.bind(this)
}
toggleMode(){
this.state.mode = this.state.mode == 'meals' ? 'users' : 'meals'
}
updateUser(user) {
this.setState({
user: user
})
}
render() {
let activity = null
if (this.state.mode == 'meals') {
activity = ()
}
else {
activity = ()
}
return (
{activity}
)
}
}
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 items = []
items.push( Hello {user.email} )
items.push( Goal: {user.goal} )
switch (user.role) {
case 'admin':
if (this.props.user.id !== this.props.currentUser.id) {
items.push( Reset User )
}
items.push( Users )
items.push( Meals )
break
case 'manager':
items.push( Users )
items.push( Meals )
case 'user':
break
}
items.push( Logout )
return (
)
// {}} />
}
}
// class ProfileModal extends React.Component {
// render() {
// return (
//
//
// )
// }
// }