<%= govuk_table do |table| %>
<%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
<%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "user", filters_count: applied_filters_count(@filter_type))) %>
<% if current_user.support? %>
<% query = searched.present? ? "?search=#{searched}" : nil %>
<%= govuk_link_to "Download (CSV)", "#{request.path}.csv#{query}", type: "text/csv", style: "white-space: nowrap" %>
<% end %>
<% end %>
<%= table.with_head do |head| %>
<%= head.with_row do |row| %>
<% row.with_cell(header: true, text: "Name and email address", html_attributes: {
scope: "col",
}) %>
<% row.with_cell(header: true, text: "Organisation and role", html_attributes: {
scope: "col",
}) %>
<% row.with_cell(header: true, text: "Last logged in", html_attributes: {
scope: "col",
}) %>
<% row.with_cell(header: true, text: "Status", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% users.each do |user| %>
<%= table.with_body do |body| %>
<%= body.with_row do |row| %>
<% row.with_cell(header: true, html_attributes: {
scope: "row",
}) do %>
<%= simple_format(user_cell(user), {}, wrapper_tag: "span") %>
<% if user.is_data_protection_officer? || user.is_key_contact? %>
<% end %>
<% if user.is_data_protection_officer? %>
<%= govuk_tag(
classes: "app-tag--small",
colour: "turquoise",
text: "Data protection officer",
) %>
<% else %>
<%= "" %>
<% end %>
<% if user.is_key_contact? %>
<%= govuk_tag(
classes: "app-tag--small",
colour: "turquoise",
text: "Key contact",
) %>
<% else %>
<%= "" %>
<% end %>
<% end %>
<% row.with_cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %>
<% row.with_cell(text: user.last_sign_in_at&.to_formatted_s(:govuk_date)) %>
<% row.with_cell(text: status_tag(user.status)) %>
<%= govuk_link_to users_path(user) do %>
User <%= user.id %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>