added deleteuser functionality

This commit is contained in:
Florian Scholdei
2019-01-23 11:55:57 +01:00
parent ff3044c365
commit 17cf42caf0
2 changed files with 22 additions and 47 deletions

View File

@@ -3,19 +3,16 @@ import React from "react";
import { translate } from "react-i18next";
import { Subtitle, DeleteButton, confirmAlert } from "@scm-manager/ui-components";
import type { User } from "@scm-manager/ui-types";
import type { History } from "history";
type Props = {
user: User,
confirmDialog?: boolean,
// dispatcher functions
fetchUserByName: (string, string) => void,
deleteUser: (user: User, callback?: () => void) => void,
deleteUser: (user: User) => void,
// context objects
t: string => string,
history: History
t: string => string
};
class DeleteUser extends React.Component<Props> {
@@ -23,14 +20,6 @@ class DeleteUser extends React.Component<Props> {
confirmDialog: true
};
userDeleted = () => {
this.props.history.push("/users");
};
deleteUser = (user: User) => {
this.props.deleteUser(user, this.userDeleted);
};
deleteUser = () => {
this.props.deleteUser(this.props.user);
};
@@ -80,34 +69,4 @@ class DeleteUser extends React.Component<Props> {
}
}
/*
const mapStateToProps = (state, ownProps) => {
const name = ownProps.match.params.name;
const user = getUserByName(state, name);
const loading = isDeleteUserPending(state, name);
const error = getDeleteUserFailure(state, name);
return {
name,
user,
loading,
error
};
};
const mapDispatchToProps = dispatch => {
return {
fetchUserByName: (link: string, name: string) => {
dispatch(fetchUserByName(link, name));
},
deleteUser: (user: User, callback?: () => void) => {
dispatch(deleteUser(user, callback));
}
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(translate("users")(DeleteUser));
*/
export default translate("users")(DeleteUser);