User input

<%= form_with(url: uprn_address_spike_path, method: 'get', local: true) do |form| %>
<%= form.label :uprn, "Enter a UPRN", class: "govuk-label" %> <%= form.text_field :uprn, class: "govuk-input", placeholder: "e.g. 100023336956" %>

OR enter an address

<%= form.label :address_line1, "Address line 1", class: "govuk-label" %> <%= form.text_field :address_line1, class: "govuk-input", placeholder: "e.g. HOME OFFICE" %>
<%= form.label :address_line2, "Address line 2", class: "govuk-label" %> <%= form.text_field :address_line2, class: "govuk-input", placeholder: "e.g. 2, MARSHAM STREET" %>
<%= form.label :town_or_city, "Town or city", class: "govuk-label" %> <%= form.text_field :town_or_city, class: "govuk-input", placeholder: "e.g. LONDON" %>
<%= form.label :postcode, "Postcode", class: "govuk-label" %> <%= form.text_field :postcode, class: "govuk-input", placeholder: "e.g. SW1P 4DF" %>
<%= form.submit "Submit", class: "govuk-button" %> <% end %>
<%if params[:uprn].present? || @address_given.present? %>

OS Places API output

<%end %> <% if params[:uprn].present? %>

UPRN given:

<%= params[:uprn] %>

<% if @error.present? %>

<%= @error %>

<% elsif @address_returned.present? %>

Match:

<%= @address_returned.address_line1 %>

<%= @address_returned.address_line2 %>

<%= @address_returned.town_or_city %>

<%= @address_returned.postcode %>

<% end %> <% elsif @address_given.present? %>

Address given:

<%= @address_given %>

<% if @error.present? %>

<%= @error %>

<% elsif @addresses_returned.present? %>

Matches:

<% @addresses_returned.each do |address_returned| %>

Address: <%= address_returned.address %>

UPRN: <%= address_returned.uprn %>

Confidence: <%= address_returned.match%> (<%= address_returned.match_description %>)


<% end %> <% end %> <% end %>