Fix: Update contact validation messages (#3500)

Fixes #3476
This commit is contained in:
thedev105
2021-12-03 10:49:11 +03:00
committed by GitHub
parent d7cfe6858e
commit 6d378eb206
8 changed files with 32 additions and 29 deletions

View File

@@ -60,8 +60,8 @@ export const actions = {
commit(types.SET_CONTACT_UI_FLAG, { isUpdating: false });
} catch (error) {
commit(types.SET_CONTACT_UI_FLAG, { isUpdating: false });
if (error.response?.data?.contact) {
throw new DuplicateContactException(error.response.data.contact);
if (error.response?.status === 422) {
throw new DuplicateContactException(error.response.data.attributes);
} else {
throw new Error(error);
}

View File

@@ -94,9 +94,10 @@ describe('#actions', () => {
it('sends correct actions if duplicate contact is found', async () => {
axios.patch.mockRejectedValue({
response: {
status: 422,
data: {
message: 'Incorrect header',
contact: { id: 1, name: 'contact-name' },
attributes: ['email'],
},
},
});