Skip to content

fixed mapping. #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/routes/ContactDetails/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ const ContactDetails = () => {
return getMyBasicInfo(authUser.handle).then(result => {
let myBasicInfo = result?.data?.result?.content[0].traits?.data[0];
if(myBasicInfo === undefined){
return addMyAddress(authUser.handle, addressMapped)
return addMyAddress(authUser.handle, addressMapped, country)
}else{
return updateMyAddress(authUser.handle, myBasicInfo, addressMapped)
return updateMyAddress(authUser.handle, myBasicInfo, addressMapped, country)
}
}).catch(e => {
setIsLoading(false);
Expand All @@ -160,10 +160,6 @@ const ContactDetails = () => {
// saving contact details
// map data before passing to server
let contactDetailsMapped = {
city: city,
state: state,
zip: zipCode,
country: country,
timeZone: timeZone,
workingHourStart: startTime,
workingHourEnd: endTime,
Expand Down Expand Up @@ -192,9 +188,7 @@ const ContactDetails = () => {
setIsLoading(true);
// save address (basic info) then contact details before navigate
e.preventDefault();
saveMyAddress().then(() => {
return saveContactDetails()
}).then(() => {
Promise.all([saveMyAddress(), saveContactDetails()]).then(() => {
setIsLoading(false);
toastr.success('Success', 'contact details saved successfully!');
navigate('/onboard/payment-setup');
Expand Down
10 changes: 6 additions & 4 deletions src/services/basicInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ export function updateMyPrimaryInterests(myusername, prevBasicInfo, interestsFla
/**
* Add my address, if the basicInfo not exists
*/
export function addMyAddress(myusername, address){
export function addMyAddress(myusername, address, country){
return axios.post(`${config.API.V5}/members/${myusername}/traits`, [{
"categoryName": "Basic Info",
"traitId": "basic_info",
"traits": {
"traitId": "basic_info",
"data": [{
"addresses": [address]
"addresses": [address],
"country": country
}]
}
}]);
Expand All @@ -63,15 +64,16 @@ export function addMyAddress(myusername, address){
/**
* Update my address
*/
export function updateMyAddress(myusername, prevBasicInfo, address){
export function updateMyAddress(myusername, prevBasicInfo, address, country){
return axios.put(`${config.API.V5}/members/${myusername}/traits`, [{
"categoryName": "Basic Info",
"traitId": "basic_info",
"traits": {
"traitId": "basic_info",
"data": [{
...prevBasicInfo,
"addresses": [address]
"addresses": [address],
"country": country
}]
}
}]);
Expand Down