diff --git a/app/javascript/dashboard/api/helpCenter/articles.js b/app/javascript/dashboard/api/helpCenter/articles.js index ea6a4f244..8bc960267 100644 --- a/app/javascript/dashboard/api/helpCenter/articles.js +++ b/app/javascript/dashboard/api/helpCenter/articles.js @@ -32,6 +32,16 @@ class ArticlesAPI extends PortalsAPI { articleObj ); } + + createArticle({ portalSlug, articleObj }) { + const { content, title, author_id, category_id } = articleObj; + return axios.post(`${this.url}/${portalSlug}/articles`, { + content, + title, + author_id, + category_id, + }); + } } export default new ArticlesAPI(); diff --git a/app/javascript/dashboard/i18n/locale/en/helpCenter.json b/app/javascript/dashboard/i18n/locale/en/helpCenter.json index 75e0e436f..7f4c7c76d 100644 --- a/app/javascript/dashboard/i18n/locale/en/helpCenter.json +++ b/app/javascript/dashboard/i18n/locale/en/helpCenter.json @@ -183,6 +183,9 @@ "ERROR": "Error while saving article" } }, + "CREATE_ARTICLE": { + "ERROR_MESSAGE": "Something went wrong. Please try again." + }, "SIDEBAR": { "SEARCH": { "PLACEHOLDER": "Search for articles" diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/EditArticle.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/EditArticle.vue index f65e24d2e..5b2b5b0f0 100644 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/EditArticle.vue +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/EditArticle.vue @@ -51,12 +51,14 @@ export default { isUpdating: false, isSaved: false, showArticleSettings: false, + alertMessage: '', }; }, computed: { ...mapGetters({ isFetching: 'articles/isFetching', articles: 'articles/articles', + selectedPortal: 'portals/getSelectedPortal', }), article() { return this.$store.getters['articles/articleById'](this.articleId); @@ -93,6 +95,7 @@ export default { this.alertMessage = error?.message || this.$t('HELP_CENTER.EDIT_ARTICLE.API.ERROR_MESSAGE'); + this.showAlert(this.alertMessage); } finally { setTimeout(() => { this.isUpdating = false; diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue index 39503efef..1938a724a 100644 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue @@ -1,22 +1,27 @@