mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix block shipping address handlers.
This commit is contained in:
parent
9f35681131
commit
47c9223d9b
2 changed files with 70 additions and 47 deletions
22
modules/ppcp-blocks/resources/js/Helper/Helper.js
Normal file
22
modules/ppcp-blocks/resources/js/Helper/Helper.js
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue