feat: Adds the ability to edit article (#5232)

This commit is contained in:
Muhsin Keloth
2022-08-16 17:55:34 +05:30
committed by GitHub
parent b5e497a6a2
commit b71291619c
19 changed files with 326 additions and 130 deletions

View File

@@ -62,18 +62,24 @@ export const actions = {
commit(types.SET_UI_FLAG, { isFetching: false });
}
},
update: async ({ commit }, params) => {
const articleId = params.id;
update: async ({ commit }, { portalSlug, articleId, ...articleObj }) => {
commit(types.ADD_ARTICLE_FLAG, {
uiFlags: {
isUpdating: true,
},
articleId,
});
try {
const { data } = await articlesAPI.update(params);
commit(types.UPDATE_ARTICLE, data);
try {
const {
data: { payload },
} = await articlesAPI.updateArticle({
portalSlug,
articleId,
articleObj,
});
commit(types.UPDATE_ARTICLE, payload);
return articleId;
} catch (error) {