<% if current_user %>
  <h1 class="govuk-heading-l">Collection resources</h1>
  <p class="govuk-body"><strong><%= govuk_link_to "Guidance for submitting social housing lettings and sales data (CORE)", guidance_path %></strong></p>
  <p class="govuk-body"><strong><%= govuk_link_to "How to upload logs in bulk", bulk_upload_lettings_log_path(id: "guidance", form: { year: current_collection_start_year }, referrer: "home") %></strong></p>
<% else %>
  <h2 class="govuk-heading-m">Collection resources</h2>
<% end %>
<% displayed_collection_resource_years.each do |collection_start_year| %>
  <p class="govuk-body">Use the <%= collection_start_year %> to <%= collection_start_year + 1 %> forms for lettings that start and sales that complete between 1 April <%= collection_start_year %> and 31 March <%= collection_start_year + 1 %>.</p>
<% end %>
<div class="app-tab__list-view">
  <%= govuk_tabs(title: "Collection resources", classes: %w[app-tab__small-headers]) do |c| %>
    <% @mandatory_lettings_collection_resources_per_year.each do |year, resources| %>
      <% c.with_tab(label: "Lettings #{year_range_format(year)}") do %>
          <%= render DocumentListComponent.new(items: document_list_component_items(resources.concat(@additional_lettings_collection_resources_per_year[year] || [])), label: "Lettings #{text_year_range_format(year)}") %>
      <% end %>
    <% end %>
    <% @mandatory_sales_collection_resources_per_year.each do |year, resources| %>
      <% c.with_tab(label: "Sales #{year_range_format(year)}") do %>
          <%= render DocumentListComponent.new(items: document_list_component_items(resources.concat(@additional_sales_collection_resources_per_year[year] || [])), label: "Sales #{text_year_range_format(year)}") %>
      <% end %>
    <% end %>
  <% end %>
</div>

<%= govuk_button_link_to "Manage collection resources", collection_resources_path, secondary: true, class: "govuk-!-margin-bottom-2" if current_user&.support? && FeatureToggle.managing_resources_enabled? %>