Chatwoot/app/javascript/dashboard/store/modules/helpCenterArticles/getters.js
2022-08-02 17:14:10 +05:30

24 lines
758 B
JavaScript

export const getters = {
uiFlags: state => helpCenterId => {
const uiFlags = state.articles.uiFlags.byId[helpCenterId];
if (uiFlags) return uiFlags;
return { isFetching: false, isUpdating: false, isDeleting: false };
},
isFetching: state => state.uiFlags.isFetching,
articleById: (...getterArguments) => articleId => {
const [state] = getterArguments;
const article = state.articles.byId[articleId];
if (!article) return undefined;
return article;
},
allArticles: (...getterArguments) => {
const [state, _getters] = getterArguments;
const articles = state.articles.allIds.map(id => {
return _getters.articleById(id);
});
return articles;
},
getMeta: state => {
return state.meta;
},
};