Created
June 7, 2021 10:20
-
-
Save dams/bb84bdd7d97a5bce6a9a0e2d43d73fe1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
let homeAddress: string | null = null; | |
let homeSearchCenter: Coordinates | null = null; | |
let workAddress: string | null = null; | |
let workSearchCenter: Coordinates | null = null; | |
const response = await api.get(`/users/${userId}/geolocate`); | |
if (!_.isNil(response.user)) { | |
homeAddress = capitalizeProperNoun(response.user.address); | |
homeSearchCenter = response.user.geoloc; | |
} | |
if (!_.isNil(response.company)) { | |
workAddress = capitalizeProperNoun(response.company.address); | |
workSearchCenter = response.company.geoloc; | |
} | |
const updateAction = { | |
address: homeAddress || workAddress, | |
homeAddress, | |
homeSearchCenter, | |
searchCenter: homeSearchCenter || workSearchCenter, | |
workAddress, | |
workSearchCenter, | |
}; | |
dispatch(alanMapLocationsUpdateAction(updateAction)); | |
} catch (error) { | |
logWarning(`Failed to geolocate user ${userId}`, { error }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment