chore: Decamelize keys on contact update

This commit is contained in:
iamsivin
2024-11-22 09:03:07 +05:30
parent ceaeba84ee
commit ca05be1c1a
7 changed files with 42 additions and 10 deletions
@@ -63,7 +63,7 @@ const updateContact = async updatedData => {
const handleFormUpdate = debounce(
updatedData => updateContact(updatedData),
500,
600,
false
);
@@ -27,7 +27,7 @@ const updateContact = async ({ id, updatedData }) => {
const handleFormUpdate = debounce(
({ id, updatedData }) => updateContact({ id, updatedData }),
500,
600,
false
);
@@ -9,7 +9,6 @@ export const labelMenuItems = [
label: 'delivery',
value: 3,
thumbnail: {
name: 'delivery',
color: '#A2FDD5',
},
isSelected: true,
@@ -19,7 +18,6 @@ export const labelMenuItems = [
label: 'lead',
value: 6,
thumbnail: {
name: 'lead',
color: '#F161C8',
},
isSelected: false,
@@ -29,7 +27,6 @@ export const labelMenuItems = [
label: 'ops-handover',
value: 4,
thumbnail: {
name: 'ops-handover',
color: '#A53326',
},
isSelected: false,
@@ -39,7 +36,6 @@ export const labelMenuItems = [
label: 'billing',
value: 1,
thumbnail: {
name: 'billing',
color: '#28AD21',
},
isSelected: false,
@@ -49,7 +45,6 @@ export const labelMenuItems = [
label: 'premium-customer',
value: 5,
thumbnail: {
name: 'premium-customer',
color: '#6FD4EF',
},
isSelected: false,
@@ -59,7 +54,6 @@ export const labelMenuItems = [
label: 'software',
value: 2,
thumbnail: {
name: 'software',
color: '#8F6EF2',
},
isSelected: false,
@@ -448,7 +448,6 @@
"SHOWING": "Showing {startItem} - {endItem} of {totalItems} contacts"
},
"CARD": {
"OF": "of",
"VIEW_DETAILS": "View details",
"EDIT_DETAILS_FORM": {
"TITLE": "Edit contact details",
@@ -4,6 +4,7 @@ import {
} from 'shared/helpers/CustomErrors';
import types from '../../mutation-types';
import ContactAPI from '../../../api/contacts';
import decamelizeKeys from 'decamelize-keys';
import AccountActionsAPI from '../../../api/accountActions';
import AnalyticsHelper from '../../../helper/AnalyticsHelper';
import { CONTACTS_EVENTS } from '../../../helper/AnalyticsHelper/events';
@@ -90,11 +91,16 @@ export const actions = {
},
update: async ({ commit }, { id, isFormData = false, ...contactParams }) => {
const decamelizedContactParams = decamelizeKeys(contactParams, {
deep: true,
});
commit(types.SET_CONTACT_UI_FLAG, { isUpdating: true });
try {
const response = await ContactAPI.update(
id,
isFormData ? buildContactFormData(contactParams) : contactParams
isFormData
? buildContactFormData(decamelizedContactParams)
: decamelizedContactParams
);
commit(types.EDIT_CONTACT, response.data.payload);
commit(types.SET_CONTACT_UI_FLAG, { isUpdating: false });