Fix block shipping address handlers.

This commit is contained in:
Pedro Silva 2024-03-19 14:05:30 +00:00
parent 9f35681131
commit 47c9223d9b
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 70 additions and 47 deletions

View file

@ -0,0 +1,22 @@
/**
* @param str
* @returns {string}
*/
export const toSnakeCase = (str) => {
return str.replace(/[\w]([A-Z])/g, function(m) {
return m[0] + "_" + m[1];
}).toLowerCase();
}
/**
* @param obj
* @returns {{}}
*/
export const convertKeysToSnakeCase = (obj) => {
const newObj = {};
Object.keys(obj).forEach((key) => {
const newKey = toSnakeCase(key);
newObj[newKey] = obj[key];
});
return newObj;
}