mockup delete button for user

This commit is contained in:
Maren Süwer
2018-07-10 15:18:37 +02:00
parent 1e86353a82
commit 0648586092
6 changed files with 148 additions and 21 deletions

View File

@@ -0,0 +1,46 @@
// @flow
import React from "react";
import { deleteUser } from '../modules/users';
import {connect} from "react-redux";
type Props = {
user: any,
deleteUser: (username: string) => void
};
class DeleteUser extends React.Component<Props> {
deleteUser = () => {
this.props.deleteUser(this.props.user.name);
};
render() {
if(this.props.user._links.delete) {
return (
<button type="button" onClick={this.deleteUser}>
Delete User
</button>
);
}
}
}
const mapStateToProps = state => {
return {
users: state.users.users
};
};
const mapDispatchToProps = dispatch => {
return {
deleteUser: (username: string) => {
dispatch(deleteUser(username));
}
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(DeleteUser);