feat: Add advanced contact filters (#3471)
Co-authored-by: Tejaswini <tejaswini@chatwoot.com> Co-authored-by: Pranav Raj S <pranav@chatwoot.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -179,4 +179,27 @@ export const actions = {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isUpdating: false });
|
||||
}
|
||||
},
|
||||
|
||||
filter: async ({ commit }, { page = 1, sortAttr, queryPayload } = {}) => {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isFetching: true });
|
||||
try {
|
||||
const {
|
||||
data: { payload, meta },
|
||||
} = await ContactAPI.filter(page, sortAttr, queryPayload);
|
||||
commit(types.CLEAR_CONTACTS);
|
||||
commit(types.SET_CONTACTS, payload);
|
||||
commit(types.SET_CONTACT_META, meta);
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isFetching: false });
|
||||
} catch (error) {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isFetching: false });
|
||||
}
|
||||
},
|
||||
|
||||
setContactFilters({ commit }, data) {
|
||||
commit(types.SET_CONTACT_FILTERS, data);
|
||||
},
|
||||
|
||||
clearContactFilters({ commit }) {
|
||||
commit(types.CLEAR_CONTACT_FILTERS);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,4 +12,7 @@ export const getters = {
|
||||
getMeta: $state => {
|
||||
return $state.meta;
|
||||
},
|
||||
getAppliedContactFilters: _state => {
|
||||
return _state.appliedFilters;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ const state = {
|
||||
isDeleting: false,
|
||||
},
|
||||
sortOrder: [],
|
||||
appliedFilters: [],
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
@@ -66,4 +66,12 @@ export const mutations = {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
[types.SET_CONTACT_FILTERS](_state, data) {
|
||||
_state.appliedFilters = data;
|
||||
},
|
||||
|
||||
[types.CLEAR_CONTACT_FILTERS](_state) {
|
||||
_state.appliedFilters = [];
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user