diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-03-20 04:48:32 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-03-20 04:48:32 +0100 |
| commit | 6ae0c07daeea0e03c832b3aa0f838778627431d8 (patch) | |
| tree | bb14c7ccff4743afd36e7175c094eb5521ab25f2 /client/components/LoggedInView.jsx | |
| parent | 50eaaa9dfaa2d4aa1230e7a6b371a60c1df8a1ab (diff) | |
view app as a different user
Diffstat (limited to 'client/components/LoggedInView.jsx')
| -rw-r--r-- | client/components/LoggedInView.jsx | 26 |
1 files changed, 22 insertions, 4 deletions
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> |
