Add redirect when segment doesn't exist
[MAILPOET-3477]
This commit is contained in:
@@ -52,7 +52,6 @@ class Form extends React.Component {
|
||||
|
||||
loadItem = (id) => {
|
||||
this.setState({ loading: true });
|
||||
|
||||
if (!this.props.endpoint) return;
|
||||
MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
@@ -74,7 +73,7 @@ class Form extends React.Component {
|
||||
loading: false,
|
||||
item: {},
|
||||
}, function failSetStateCallback() {
|
||||
this.props.history.push('/new');
|
||||
this.props.history.push('/lists');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@@ -108,16 +108,22 @@ const DynamicSegmentForm: React.FunctionComponent = () => {
|
||||
},
|
||||
})
|
||||
.done((response) => {
|
||||
setItem(convertSavedData(response.data));
|
||||
setSegmentType(findSegmentType(response.data));
|
||||
if (response.data.is_plugin_missing) {
|
||||
history.push('/segments');
|
||||
} else {
|
||||
setItem(convertSavedData(response.data));
|
||||
setSegmentType(findSegmentType(response.data));
|
||||
}
|
||||
})
|
||||
.fail(compose([setErrors, prop('errors')]));
|
||||
.fail(() => {
|
||||
history.push('/segments');
|
||||
});
|
||||
}
|
||||
|
||||
if (match.params.id !== undefined) {
|
||||
loadSegment(match.params.id);
|
||||
}
|
||||
}, [segmentFilters, match.params.id]);
|
||||
}, [segmentFilters, match.params.id, history]);
|
||||
|
||||
function handleSave(e): void {
|
||||
e.preventDefault();
|
||||
|
Reference in New Issue
Block a user