2018-07-10 15:18:37 +02:00
|
|
|
// @flow
|
|
|
|
|
import React from "react";
|
2018-07-11 12:02:53 +02:00
|
|
|
import type { User } from "../types/User";
|
2018-07-10 15:18:37 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2018-07-11 12:02:53 +02:00
|
|
|
user: User,
|
2018-07-12 14:23:09 +02:00
|
|
|
deleteUser: (link: string) => void,
|
2018-07-10 15:18:37 +02:00
|
|
|
};
|
|
|
|
|
|
2018-07-12 14:23:09 +02:00
|
|
|
class DeleteUserButton extends React.Component<Props> {
|
|
|
|
|
|
2018-07-10 15:18:37 +02:00
|
|
|
deleteUser = () => {
|
2018-07-10 16:37:27 +02:00
|
|
|
this.props.deleteUser(this.props.user._links.delete.href);
|
2018-07-10 15:18:37 +02:00
|
|
|
};
|
|
|
|
|
|
2018-07-10 16:37:27 +02:00
|
|
|
isDeletable = () => {
|
|
|
|
|
return this.props.user._links.delete;
|
2018-07-10 15:18:37 +02:00
|
|
|
};
|
|
|
|
|
|
2018-07-10 16:37:27 +02:00
|
|
|
render() {
|
|
|
|
|
return (
|
2018-07-12 14:23:09 +02:00
|
|
|
|
|
|
|
|
<button type="button" onClick={(e) => { if (window.confirm('Are you sure you wish to delete this item?')) this.deleteUser() } }>
|
|
|
|
|
Delete User
|
2018-07-10 16:37:27 +02:00
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-10 15:18:37 +02:00
|
|
|
|
2018-07-12 14:23:09 +02:00
|
|
|
export default DeleteUserButton;
|