From a77e412cb030d92992e5e541879f9a0662f7073b Mon Sep 17 00:00:00 2001
From: Jules Laplace <jules@okfoc.us>
Date: Mon, 20 Mar 2017 05:17:29 +0100
Subject: admins and managers can delete users

---
 client/components/UserList.jsx | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

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

diff --git a/client/components/UserList.jsx b/client/components/UserList.jsx
index 3e87ec5..7430e61 100644
--- a/client/components/UserList.jsx
+++ b/client/components/UserList.jsx
@@ -20,7 +20,7 @@ export default class UserList extends React.Component {
       console.error(error)
     })
     this.pick.bind(this)
-    console.log(props)
+    this.handleDelete.bind(this)
   }
   pick(user){
     // bubble this up..
@@ -28,6 +28,14 @@ export default class UserList extends React.Component {
     console.log(this)
     this.props.updateUser(user)
   }
+  handleDelete(userid) {
+    const users = this.state.data.filter((data) => {
+      return data.id !== userid
+    })
+    this.setState({
+      data: users
+    })
+  }
   render() {
     console.log(this.state.data)
     const items = this.state.data.map((user,i) => {
@@ -36,7 +44,7 @@ export default class UserList extends React.Component {
           user={user}
           activeUser={this.props.user}
           onClick={(user) => this.pick(user)}
-          onDelete={this.handleDelete} />
+          onDelete={(userid) => this.handleDelete(userid)} />
       )
     })
     return (
-- 
cgit v1.2.3-70-g09d2

