<% potential_errors, critical_errors = bulk_upload_errors.partition { |error| error.category == "soft_validation" } %>
    <% if critical_errors.any? %>
      
Critical errors
      These errors must be fixed to complete your logs.
      <%= govuk_table(html_attributes: { class: potential_errors.any? ? "" : "no-bottom-border" })  do |table| %>
        <%= table.with_head do |head| %>
          <% head.with_row do |row| %>
            <% row.with_cell(header: true, text: "Cell") %>
            <% row.with_cell(header: true, text: "Question") %>
            <% row.with_cell(header: true, text: "Error") %>
            <% row.with_cell(header: true, text: "Specification") %>
          <% end %>
          <%= table.with_body do |body| %>
            <% critical_errors.each do |error| %>
              <% body.with_row do |row| %>
                  <% row.with_cell(text: error.cell) %>
                  <% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %>
                  <% row.with_cell(text: error.error.html_safe, html_attributes: { class: "govuk-!-font-weight-bold govuk-!-width-one-half" }) %>
                  <% row.with_cell(text: error.field.humanize) %>
              <% end %>
            <% end %>
          <% end %>
        <% end %>
      <% end %>
    <% end %>
    <% if potential_errors.any? %>
      
Confirmation needed
      Potential data discrepancies exist in the following cells.
Please resolve all critical errors and review the cells with data discrepancies before re-uploading the file. Bulk confirmation of potential discrepancies is accessible only after all critical errors have been resolved.
        <%= govuk_table(html_attributes: { class: "no-bottom-border" })  do |table| %>
          <%= table.with_head do |head| %>
            <% head.with_row do |row| %>
              <% row.with_cell(header: true, text: "Cell") %>
              <% row.with_cell(header: true, text: "Question") %>
              <% row.with_cell(header: true, text: "Confirmation needed") %>
              <% row.with_cell(header: true, text: "Specification") %>
            <% end %>
          <% end %>
        <%= table.with_body do |body| %>
          <% potential_errors.group_by(&:error).each_with_index do |(error_message, errors), group_index| %>
            <% total_groups = potential_errors.group_by(&:error).size %>
            <% errors.each_with_index do |error, index| %>
              <% row_class = row_classes(index, errors.size) %>
              <% body.with_row(html_attributes: { class: row_class }) do |row| %>
                <% row.with_cell(text: error.cell) %>
                <% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %>
                <% if index == 0 %>
                  <% cell_class = cell_classes(group_index, total_groups) %>
                  <% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: cell_class }) %>
                <% end %>
                <% row.with_cell(text: error.field.humanize) %>
              <% end %>
            <% end %>
          <% end %>
        <% end %>
        <% end %>
    <% end %>