Change replace create with update

pull/1012/head
Andrew Watkins 2017-03-13 15:19:55 -07:00
parent 74f5961f1a
commit 3f08f69c3e
1 changed files with 7 additions and 17 deletions

View File

@ -78,23 +78,13 @@ export const SourcePage = React.createClass({
handleSubmit(newSource) {
const {router, params, addFlashMessage} = this.props;
if (this.state.editMode) {
updateSource(newSource).then(({data: sourceFromServer}) => {
this.props.updateSourceAction(sourceFromServer);
router.push(`/sources/${params.sourceID}/manage-sources`);
addFlashMessage({type: 'success', text: 'The source was successfully updated'});
}).catch(() => {
addFlashMessage({type: 'error', text: 'There was a problem updating the source. Check the settings'});
});
} else {
createSource(newSource).then(({data: sourceFromServer}) => {
this.props.addSourceAction(sourceFromServer);
router.push(`/sources/${params.sourceID}/manage-sources`);
addFlashMessage({type: 'success', text: 'The source was successfully created'});
}).catch(() => {
addFlashMessage({type: 'error', text: 'There was a problem creating the source. Check the settings'});
});
}
updateSource(newSource).then(({data: sourceFromServer}) => {
this.props.updateSourceAction(sourceFromServer);
router.push(`/sources/${params.sourceID}/manage-sources`);
addFlashMessage({type: 'success', text: 'The source info saved'});
}).catch(() => {
addFlashMessage({type: 'error', text: 'There was a problem updating the source. Check the settings'});
});
},