feat(dossier): use new combobox on champ adresse

This commit is contained in:
Paul Chavard 2023-10-03 18:14:42 +02:00
parent ae450a2d2b
commit 89582d2e09
3 changed files with 14 additions and 12 deletions

View file

@ -0,0 +1,11 @@
class DataSources::AdresseController < ApplicationController
def search
if params[:q].present? && params[:q].length > 3
response = Typhoeus.get("#{API_ADRESSE_URL}/search", params: { q: params[:q], limit: 10 })
result = JSON.parse(response.body, symbolize_names: true)
render json: result[:features].map { { label: _1[:properties][:label], value: _1[:properties][:label] } }
else
render json: []
end
end
end