mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 18:51:10 +01:00
Made EditGroup prettier
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import GroupForm from "../components/GroupForm";
|
||||
import { modifyGroup, fetchGroup } from "../modules/groups"
|
||||
import { modifyGroup, fetchGroup } from "../modules/groups";
|
||||
import type { History } from "history";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import type { Group } from "../types/Group"
|
||||
import { isModifyGroupPending, getModifyGroupFailure } from "../modules/groups"
|
||||
import type { Group } from "../types/Group";
|
||||
import { isModifyGroupPending, getModifyGroupFailure } from "../modules/groups";
|
||||
import ErrorNotification from "../../components/ErrorNotification";
|
||||
|
||||
type Props = {
|
||||
@@ -20,39 +20,47 @@ type Props = {
|
||||
|
||||
class EditGroup extends React.Component<Props> {
|
||||
groupModified = (group: Group) => () => {
|
||||
this.props.fetchGroup(group.name)
|
||||
this.props.history.push(`/group/${group.name}`)
|
||||
}
|
||||
this.props.fetchGroup(group.name);
|
||||
this.props.history.push(`/group/${group.name}`);
|
||||
};
|
||||
|
||||
modifyGroup = (group: Group) => {
|
||||
this.props.modifyGroup(group, this.groupModified(group));
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { group, loading, error } = this.props;
|
||||
return <div>
|
||||
<ErrorNotification error={error} />
|
||||
<GroupForm group={group} submitForm={(group) =>{this.modifyGroup(group)}} loading={loading}/>
|
||||
</div>
|
||||
return (
|
||||
<div>
|
||||
<ErrorNotification error={error} />
|
||||
<GroupForm
|
||||
group={group}
|
||||
submitForm={group => {
|
||||
this.modifyGroup(group);
|
||||
}}
|
||||
loading={loading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const loading = isModifyGroupPending(state, ownProps.group.name)
|
||||
const error = getModifyGroupFailure(state, ownProps.group.name)
|
||||
const loading = isModifyGroupPending(state, ownProps.group.name);
|
||||
const error = getModifyGroupFailure(state, ownProps.group.name);
|
||||
return {
|
||||
loading,
|
||||
error
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
modifyGroup: (group: Group, callback?: () => void) => {
|
||||
dispatch(modifyGroup(group, callback))
|
||||
modifyGroup: (group: Group, callback?: () => void) => {
|
||||
dispatch(modifyGroup(group, callback));
|
||||
},
|
||||
fetchGroup: (name: string) => {
|
||||
dispatch(fetchGroup(name))
|
||||
dispatch(fetchGroup(name));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user