diff --git a/app/backend/wells/urls.py b/app/backend/wells/urls.py index 06774b3f2..eeb9a3c48 100644 --- a/app/backend/wells/urls.py +++ b/app/backend/wells/urls.py @@ -114,5 +114,9 @@ # Well Licensing status endpoint from e-Licensing. url(api_path_prefix() + r'/wells/licensing$', - views.well_licensing, name='well-licensing') + views.well_licensing, name='well-licensing'), + + # get geocoder address + url(api_path_prefix() + r'/wells/geocoder$', + views.AddressGeocoder.as_view(), name='address-geocoder'), ] diff --git a/app/backend/wells/views.py b/app/backend/wells/views.py index 5bad3b0ab..b1ec3604c 100644 --- a/app/backend/wells/views.py +++ b/app/backend/wells/views.py @@ -893,3 +893,15 @@ def get_queryset(self): qs = qs.filter(well_tag_number__in=wells) return qs +class AddressGeocoder(APIView): + def get(self, request,**kwargs): + GEOCODER_ADDRESS_URL = get_env_variable('GEOCODER_ADDRESS_API_BASE') + self.request.query_params.get('searchTag') + response = requests.get(GEOCODER_ADDRESS_URL) + # Check if the request was successful (status code 200) + if response.status_code == 200: + data = response.json() + # Create a Django JsonResponse object and return it + return JsonResponse(data) + else: + # If the request was not successful, return an appropriate HTTP response + return JsonResponse({'error': f"Error: {response.status_code} - {response.text}"}, status=500) diff --git a/app/frontend/src/common/services/ApiService.js b/app/frontend/src/common/services/ApiService.js index 9527e6419..6bb22a866 100644 --- a/app/frontend/src/common/services/ApiService.js +++ b/app/frontend/src/common/services/ApiService.js @@ -94,6 +94,9 @@ const ApiService = { incrementFileCount(resource, documentType){ return axios.get(`${resource}/sum`, {params: { inc: true, documentType}}) }, + getAddresses(searchTag){ + return axios.get(`wells/geocoder`, {params: { searchTag: searchTag }}) + }, } export default ApiService diff --git a/app/frontend/src/submissions/components/SubmissionForm/Location.vue b/app/frontend/src/submissions/components/SubmissionForm/Location.vue index b07bb0b61..b80d127df 100644 --- a/app/frontend/src/submissions/components/SubmissionForm/Location.vue +++ b/app/frontend/src/submissions/components/SubmissionForm/Location.vue @@ -38,10 +38,23 @@ Licensed under the Apache License, Version 2.0 (the "License"); id="wellStreetAddress" type="text" label="Street address" + @input="fetchAddressSuggestions" + v-on:focus="showList(true)" + v-on:blur="showList(false)" :errors="errors['street_address']" :loaded="fieldsLoaded['street_address']" :disabled="sameAsOwnerAddress" > + +