<% content_for :title, "What support does this scheme provide?" %>

<% content_for :before_content do %>
  <%= govuk_back_link(href: scheme_back_button_path(@scheme, "support")) %>
<% end %>

<%= form_for(@scheme, method: :patch) do |f| %>
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <%= f.govuk_error_summary %>

      <%= render partial: "organisations/headings", locals: { main: "What support does this scheme provide?", sub: @scheme.service_name } %>
      <%= govuk_inset_text(text: "Only update a scheme if you’re fixing an error. If the scheme is changing,  create a new scheme.") if @scheme.confirmed? %>

      <% support_level_options_hints = { "Low level": "Staff visiting once a week, fortnightly or less.", "Medium level": "Staff on site daily or making frequent visits with some out-of-hours cover.", "High level": "Intensive level of staffing provided on a 24-hour basis." } %>

      <% support_level_options_with_hints = Scheme.support_types.keys.excluding("Missing").excluding("Floating support").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: support_level_options_hints[key.to_sym]) } %>

      <%= f.govuk_collection_radio_buttons :support_type,
                                           support_level_options_with_hints,
                                           :id,
                                           :name,
                                           :description,
                                           legend: { text: "Level of support given", size: "m" } %>

      <% intended_length_of_stay_options_hints = { "Very short stay": "Up to one month.", "Short stay": "Up to one year.", "Medium stay": "More than one year but with an expectation to move on.", "Permanent": "Provides a home for life with no requirement for the tenant to move." } %>

      <% intended_length_of_stay_options_with_hints = Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: intended_length_of_stay_options_hints[key.to_sym]) } %>

      <%= f.govuk_collection_radio_buttons :intended_stay,
                                           intended_length_of_stay_options_with_hints,
                                           :id,
                                           :name,
                                           :description,
                                           legend: { text: "Intended length of stay", size: "m" } %>

      <%= f.hidden_field :page, value: "support" %>

      <% if params[:referrer] == "check-answers" %>
        <%= f.hidden_field :check_answers, value: "true" %>
        <%= f.govuk_submit "Save changes" %>
      <% else %>
        <%= f.govuk_submit "Save and continue" %>
      <% end %>
    </div>
  </div>
<% end %>