snake case - camel case transformations
This commit is contained in:
@@ -13,6 +13,7 @@ import {updateMessages} from '../notification/notificationActions';
|
|||||||
import {setDialogOpenFlag} from '../dialog/dialogActions';
|
import {setDialogOpenFlag} from '../dialog/dialogActions';
|
||||||
import {recieveProfileInfo} from './profileSettingsActions';
|
import {recieveProfileInfo} from './profileSettingsActions';
|
||||||
import { fromWiaasProfileInfo } from '../../helpers/ProfileHelper';
|
import { fromWiaasProfileInfo } from '../../helpers/ProfileHelper';
|
||||||
|
import { toWiaasAddress } from '../../helpers/AddressHelper';
|
||||||
|
|
||||||
const client = new HtmlClient();
|
const client = new HtmlClient();
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ export const saveProfileAddress = (idUser, profileAddress) => {
|
|||||||
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/profile-addresses`,
|
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/profile-addresses`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: {
|
data: {
|
||||||
'profile_address': JSON.stringify(profileAddress)
|
'profile_address': JSON.stringify(toWiaasAddress(profileAddress))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@@ -80,7 +81,7 @@ export const saveBillingAddress = (idUser, billingAddress) => {
|
|||||||
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/billing-addresses`,
|
url: `${API_SERVER}/wp-json/wiaas/customer/${idUser}/billing-addresses`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: {
|
data: {
|
||||||
'billing_address': JSON.stringify(billingAddress)
|
'billing_address': JSON.stringify(toWiaasAddress(billingAddress))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|||||||
29
frontend/src/helpers/AddressHelper.js
Normal file
29
frontend/src/helpers/AddressHelper.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
export const fromWiaasAddress = (address) => {
|
||||||
|
return {
|
||||||
|
id: address.id,
|
||||||
|
countryName: address.country_name,
|
||||||
|
deliveryMail: address.delivery_mail,
|
||||||
|
idCountrySelected: address.id_country_selected,
|
||||||
|
city: address.city,
|
||||||
|
detailedAddress: address.detailed_address,
|
||||||
|
zipCode: address.zip_code,
|
||||||
|
firstName: address.first_name,
|
||||||
|
lastName: address.lastName,
|
||||||
|
invoiceMail: address.invoice_mail
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toWiaasAddress = (address) => {
|
||||||
|
return {
|
||||||
|
id: address.id,
|
||||||
|
country_name: address.countryName,
|
||||||
|
delivery_mail: address.deliveryMail,
|
||||||
|
id_country_selected: address.idCountrySelected,
|
||||||
|
city: address.city,
|
||||||
|
detailed_address: address.detailedAddress,
|
||||||
|
zip_code: address.zipCode,
|
||||||
|
first_name: address.firstName,
|
||||||
|
last_name: address.lastName,
|
||||||
|
invoice_mail: address.invoiceMail
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { fromWiaasAddress } from "./AddressHelper";
|
||||||
|
|
||||||
export const fromWiaasProfileInfo = (profileInfo) => {
|
export const fromWiaasProfileInfo = (profileInfo) => {
|
||||||
return {
|
return {
|
||||||
id: profileInfo.id,
|
id: profileInfo.id,
|
||||||
@@ -8,8 +10,8 @@ export const fromWiaasProfileInfo = (profileInfo) => {
|
|||||||
mail: profileInfo.mail,
|
mail: profileInfo.mail,
|
||||||
name: profileInfo.name,
|
name: profileInfo.name,
|
||||||
phone: profileInfo.phone,
|
phone: profileInfo.phone,
|
||||||
billingAddresses: profileInfo.billing_addresses,
|
billingAddresses: profileInfo.billing_addresses.map(address => fromWiaasAddress(address)),
|
||||||
profileAddresses: profileInfo.profile_addresses,
|
profileAddresses: profileInfo.profile_addresses.map(address => fromWiaasAddress(address)),
|
||||||
userType: profileInfo.user_type,
|
userType: profileInfo.user_type,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user