<div class="govuk-grid-row">
  <div class="govuk-grid-column-two-thirds">
    <h1 class="govuk-heading-l"><%= duplicate_list_header(@duplicates[:lettings].count + @duplicates[:sales].count) %></h1>
    <p class="govuk-body">
      These logs are duplicates because they have the same answers for certain fields.
    </p>
    <p class="govuk-body">
      Review each set of logs and either delete any duplicates or change any incorrect answers.
    </p>
  </div>
</div>

<%= govuk_table do |table| %>
  <%= table.with_head do |head| %>
    <%= head.with_row do |row| %>
      <% row.with_cell header: true, text: "Type of logs" %>
      <% row.with_cell header: true, text: "Log IDs" %>
      <% row.with_cell header: true %>
    <% end %>
  <% end %>
  <%= table.with_body do |body| %>
    <% @duplicates[:lettings].each do |duplicate_set| %>
      <% body.with_row do |row| %>
        <% row.with_cell text: "Lettings" %>
        <% row.with_cell text: duplicate_set.map { |id| "Log #{id}" }.join(", ") %>
        <% row.with_cell do %>
          <%= govuk_link_to "Review logs", lettings_log_duplicate_logs_path(duplicate_set.first, original_log_id: duplicate_set.first, referrer: params[:referrer], organisation_id: params[:organisation_id]) %>
        <% end %>
      <% end %>
    <% end %>
    <% @duplicates[:sales].each do |duplicate_set| %>
      <% body.with_row do |row| %>
        <% row.with_cell text: "Sales" %>
        <% row.with_cell text: duplicate_set.map { |id| "Log #{id}" }.join(", ") %>
        <% row.with_cell do %>
          <%= govuk_link_to "Review logs", sales_log_duplicate_logs_path(duplicate_set.first, original_log_id: duplicate_set.first, referrer: params[:referrer], organisation_id: params[:organisation_id]) %>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
<% end %>