Feat: Create contact from contacts page (#1806)
* Add contact create modal to contacts page * Test cases * Review fixes
This commit is contained in:
committed by
GitHub
parent
6ba25bae3d
commit
c17380d48a
@@ -1,4 +1,7 @@
|
||||
import { DuplicateContactException } from 'shared/helpers/CustomErrors';
|
||||
import {
|
||||
DuplicateContactException,
|
||||
ExceptionWithMessage,
|
||||
} from 'shared/helpers/CustomErrors';
|
||||
import types from '../../mutation-types';
|
||||
import ContactAPI from '../../../api/contacts';
|
||||
|
||||
@@ -64,6 +67,22 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
create: async ({ commit }, userObject) => {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isCreating: true });
|
||||
try {
|
||||
const response = await ContactAPI.create(userObject);
|
||||
commit(types.SET_CONTACT_ITEM, response.data.payload.contact);
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isCreating: false });
|
||||
} catch (error) {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isCreating: false });
|
||||
if (error.response?.data?.message) {
|
||||
throw new ExceptionWithMessage(error.response.data.message);
|
||||
} else {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updatePresence: ({ commit }, data) => {
|
||||
commit(types.UPDATE_CONTACTS_PRESENCE, data);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user