Redirect user to org detail page after successful POST.

This commit is contained in:
kialam
2019-01-08 16:09:30 -05:00
parent a1d1dc7a24
commit c5cd659c83

View File

@@ -75,6 +75,7 @@ class OrganizationAdd extends React.Component {
const data = Object.assign({}, { ...this.state }); const data = Object.assign({}, { ...this.state });
try { try {
const { data: response } = await api.createOrganization(data); const { data: response } = await api.createOrganization(data);
console.log(response);
const url = response.related.instance_groups; const url = response.related.instance_groups;
const selected = this.state.results.filter(group => group.isChecked); const selected = this.state.results.filter(group => group.isChecked);
try { try {
@@ -82,17 +83,23 @@ class OrganizationAdd extends React.Component {
this.resetForm(); this.resetForm();
} catch (err) { } catch (err) {
this.setState({ createInstanceGroupsError: err }) this.setState({ createInstanceGroupsError: err })
} finally {
this.onSuccess(response.id);
} }
} }
catch (err) { catch (err) {
this.setState({ onSubmitError: err }) this.setState({ onSubmitError: err })
} }
} }
onCancel() { onCancel() {
this.props.history.push('/organizations'); this.props.history.push('/organizations');
} }
onSuccess(id) {
this.props.history.push(`/organizations/${id}`);
}
async componentDidMount() { async componentDidMount() {
const { api } = this.props; const { api } = this.props;
try { try {