<% content_for :title, "Add a location to this scheme" %>

<% content_for :before_content do %>
  <%= govuk_back_link(
        href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_type_of_unit_path(@scheme, @location, route: params[:route]),
      ) %>
<% end %>

<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %>
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <%= f.govuk_error_summary %>

      <%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.mobility_type"), sub: "Add a location to #{@scheme.service_name}" } %>

      <%= f.govuk_collection_radio_buttons :mobility_type,
                                           mobility_type_selection,
                                           :id,
                                           :name,
                                           :description,
                                           legend: nil %>

      <div class="govuk-button-group">
        <% if params[:referrer] == "check_answers" %>
          <%= f.govuk_submit "Save changes" %>
          <%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %>
        <% elsif params[:referrer] == "details" %>
          <%= f.govuk_submit "Save changes" %>
          <%= govuk_link_to "Cancel", scheme_location_path(@scheme, @location), secondary: true %>
        <% else %>
          <%= f.govuk_submit "Save and continue" %>
          <%= govuk_link_to "Skip for now", scheme_location_availability_path(@scheme, @location), secondary: true %>
        <% end %>
      </div>
    </div>
  </div>
<% end %>