From 23f9fb7833860eb86759a1dd5f79a78f96995d55 Mon Sep 17 00:00:00 2001 From: Maxi Redigonda Date: Thu, 22 Mar 2018 11:57:33 -0300 Subject: [PATCH] Sets loading state in the form when the user presses SAVE --- client/src/app-components/article-add-modal.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/src/app-components/article-add-modal.js b/client/src/app-components/article-add-modal.js index e0e34d86..0a5e4346 100644 --- a/client/src/app-components/article-add-modal.js +++ b/client/src/app-components/article-add-modal.js @@ -17,11 +17,15 @@ class ArticleAddModal extends React.Component { position: React.PropTypes.number.isRequired }; + state = { + loading: false + }; + render() { return (
-
+ {i18n('ADD_ARTICLE')} @@ -35,6 +39,10 @@ class ArticleAddModal extends React.Component { } onAddNewArticleFormSubmit(form) { + this.setState({ + loading: true + }); + API.call({ path: '/article/add', data: { @@ -49,8 +57,12 @@ class ArticleAddModal extends React.Component { if(this.props.onChange) { this.props.onChange(); } + }).catch(() => { + this.setState({ + loading: false + }); }); } } -export default ArticleAddModal; \ No newline at end of file +export default ArticleAddModal;