<% title = "#{action.humanize} #{@scheme.service_name}" %>
<% content_for :title, title %>

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

<%= form_with model: @scheme_deactivation_period, url: toggle_scheme_form_path(action, @scheme), method: "patch", local: true do |f| %>
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <% start_date = FormHandler.instance.earliest_open_for_editing_collection_start_date %>
      <%= f.govuk_error_summary %>
      <span class="govuk-caption-m"><%= title %></span>
      <h1 class="govuk-heading-m"><%= I18n.t("questions.scheme.toggle_active.apply_from") %></h1>
      <%= govuk_warning_text text: I18n.t("warnings.scheme.#{action}.existing_logs") %>
      <p class="govuk-hint"><%= I18n.t("hints.scheme.toggle_active", date: start_date.to_formatted_s(:govuk_date)) %></p>
      <%= f.govuk_radio_buttons_fieldset date_type_question(action),
                                         legend: { text: I18n.t("questions.scheme.toggle_active.apply_from"), hidden: true } do %>
        <%= f.govuk_radio_button date_type_question(action),
                                 "default",
                                 label: { text: "From the start of the open collection period (#{start_date.to_formatted_s(:govuk_date)})" } %>
        <%= f.govuk_radio_button date_type_question(action),
                                 "other",
                                 label: { text: "For tenancies starting after a certain date" },
                                 **basic_conditional_html_attributes({ "deactivation_date" => %w[other] }, "scheme") do %>
          <%= render partial: "components/date_picker", locals: {
                    resource: @scheme,
                    question_id: date_question(action),
                    legend: { text: "Date", size: "m" },
                    resource_type: "scheme",
                    hint: "For example, 27/3/2025",
                    f:,
          } %>
        <% end %>
      <% end %>
      <%= f.govuk_submit "Continue" %>
    </div>
  </div>
<% end %>