mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 12:37:56 +00:00
feat: Adds the ability to create a new article (#5255)
This commit is contained in:
@@ -32,13 +32,20 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
create: async ({ commit }, params) => {
|
||||
create: async ({ commit, dispatch }, { portalSlug, ...articleObj }) => {
|
||||
commit(types.SET_UI_FLAG, { isCreating: true });
|
||||
try {
|
||||
const { data } = await articlesAPI.create(params);
|
||||
const { id: articleId } = data;
|
||||
commit(types.ADD_ARTICLE, data);
|
||||
const {
|
||||
data: { payload },
|
||||
} = await articlesAPI.createArticle({
|
||||
portalSlug,
|
||||
articleObj,
|
||||
});
|
||||
const { id: articleId, portal } = payload;
|
||||
commit(types.ADD_ARTICLE, payload);
|
||||
commit(types.ADD_ARTICLE_ID, articleId);
|
||||
commit(types.ADD_ARTICLE_FLAG, articleId);
|
||||
dispatch('portals/updatePortal', portal, { root: true });
|
||||
return articleId;
|
||||
} catch (error) {
|
||||
return throwErrorMessage(error);
|
||||
@@ -63,7 +70,7 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
update: async ({ commit }, { portalSlug, articleId, ...articleObj }) => {
|
||||
commit(types.ADD_ARTICLE_FLAG, {
|
||||
commit(types.UPDATE_ARTICLE_FLAG, {
|
||||
uiFlags: {
|
||||
isUpdating: true,
|
||||
},
|
||||
@@ -85,7 +92,7 @@ export const actions = {
|
||||
} catch (error) {
|
||||
return throwErrorMessage(error);
|
||||
} finally {
|
||||
commit(types.ADD_ARTICLE_FLAG, {
|
||||
commit(types.UPDATE_ARTICLE_FLAG, {
|
||||
uiFlags: {
|
||||
isUpdating: false,
|
||||
},
|
||||
@@ -94,7 +101,7 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
delete: async ({ commit }, articleId) => {
|
||||
commit(types.ADD_ARTICLE_FLAG, {
|
||||
commit(types.UPDATE_ARTICLE_FLAG, {
|
||||
uiFlags: {
|
||||
isDeleting: true,
|
||||
},
|
||||
@@ -109,7 +116,7 @@ export const actions = {
|
||||
} catch (error) {
|
||||
return throwErrorMessage(error);
|
||||
} finally {
|
||||
commit(types.ADD_ARTICLE_FLAG, {
|
||||
commit(types.UPDATE_ARTICLE_FLAG, {
|
||||
uiFlags: {
|
||||
isDeleting: false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user