feat: Create modal to merge two contacts (#2457)

This commit is contained in:
Nithin David Thomas
2021-10-13 18:35:13 +05:30
committed by GitHub
parent 6c3e2a0bd3
commit b33701a666
16 changed files with 437 additions and 110 deletions

View File

@@ -4,6 +4,7 @@ import {
} from 'shared/helpers/CustomErrors';
import types from '../../mutation-types';
import ContactAPI from '../../../api/contacts';
import AccountActionsAPI from '../../../api/accountActions';
export const actions = {
search: async ({ commit }, { search, page, sortAttr, label }) => {
@@ -137,6 +138,18 @@ export const actions = {
commit(types.SET_CONTACT_ITEM, data);
},
merge: async ({ commit }, { childId, parentId }) => {
commit(types.SET_CONTACT_UI_FLAG, { isMerging: true });
try {
const response = await AccountActionsAPI.merge(parentId, childId);
commit(types.SET_CONTACT_ITEM, response.data);
} catch (error) {
throw new Error(error);
} finally {
commit(types.SET_CONTACT_UI_FLAG, { isMerging: false });
}
},
deleteContactThroughConversations: ({ commit }, id) => {
commit(types.DELETE_CONTACT, id);
commit(types.CLEAR_CONTACT_CONVERSATIONS, id, { root: true });