From bf7ac6af587f68553b83a54fcb724dfc9d684644 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 20 Mar 2017 01:03:23 +0100 Subject: refactor frontend --- client/components/UserList.jsx | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 client/components/UserList.jsx (limited to 'client/components/UserList.jsx') diff --git a/client/components/UserList.jsx b/client/components/UserList.jsx new file mode 100644 index 0000000..fb93b9f --- /dev/null +++ b/client/components/UserList.jsx @@ -0,0 +1,75 @@ +import React from 'react' + +import client from '../client' + +export default class UserList extends React.Component { + constructor(props){ + super() + console.log("WHAT") + this.state = { + users: [], + } +// client.service('users').find({ +// query: { +// '$sort': { 'date': '-1' }, +// token: client.get('token'), +// }, +// }).then((data) => { +// this.setState(data) +// }).catch((error) => { +// console.error(error) +// }) + this.pick.bind(this) + } + pick(){ + } + render() { + const items = this.state.users.map((item,i) => { + return ( + + ) + }) + return ( +
+ {items} +
+ ) + } +} + +class UserItem extends React.Component { + constructor() { + super() + this.remove = this.remove.bind(this) + } + remove(e) { + e.stopPropagation() + const userid = this.props.user.id + const usersService = client.service('users') + const params = { query: { token: client.get('token') } } + usersService.remove(userid, params).then(result => { + this.props.onDelete(userid) + }).catch(error => { + console.error(error) + }) + } + render() { + const user = this.props.user + // const canEdit = this.props.user.userid === this.props.currentUser.id ? 'canEdit' : '' + const canEdit = 'canEdit' + const date = parseDate(meal.date) + const time = parseTime(meal.date) + return ( +
this.props.onClick(meal)}> +
{meal.name}
+
{meal.calories} cal
+
{date}
+
{time}
+
x
+
+ ) + } +} -- cgit v1.2.3-70-g09d2