-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5406bae
commit fd754c8
Showing
8 changed files
with
108 additions
and
13 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,7 @@ | |
font-weight: bold; | ||
color: red; | ||
} | ||
|
||
.retailerEditorGeocode { | ||
margin-left: 10px; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import secrets from "@/helpers/secrets"; | ||
import config from "../config.json"; | ||
import { setDefaults, geocode, RequestType } from "react-geocode"; | ||
import { getStorageValue } from "./storage"; | ||
|
||
const geocodeAddress = async ( | ||
address1, | ||
address2, | ||
town, | ||
county, | ||
postcode, | ||
country | ||
) => { | ||
// This sets default values for language and region for geocoding requests. | ||
const apiKey = getStorageValue(secrets.mapsApiKey); | ||
setDefaults({ | ||
key: apiKey, | ||
language: config.region.geocodingLanguage, | ||
region: config.region.geocodingRegion, | ||
}); | ||
|
||
// Construct an address from its components | ||
const address = [ | ||
address1, | ||
address1, | ||
address2, | ||
town, | ||
county, | ||
postcode, | ||
country, | ||
].join(","); | ||
|
||
try { | ||
// Geocode the address | ||
const response = await geocode(RequestType.ADDRESS, address); | ||
const location = response.results[0].geometry.location; | ||
return location; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
export { geocodeAddress }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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