h1 = InternalUser.model_name.human(count: 2)

- if current_user.admin?
  = render(layout: 'shared/form_filters') do |f|
    .col-auto
      = f.label(:consumer_id_eq, t('activerecord.attributes.internal_user.consumer'), class: 'visually-hidden form-label')
      = f.collection_select(:consumer_id_eq, Consumer.with_internal_users, :id, :name, class: 'form-control', include_blank: true, prompt: t('activerecord.attributes.internal_user.consumer'))
    .col-sm
      = f.label(:email_cont, t('activerecord.attributes.internal_user.email'), class: 'visually-hidden form-label')
      = f.search_field(:email_cont, class: 'form-control', placeholder: t('activerecord.attributes.internal_user.email'))
    .col-auto
      = f.select :platform_admin_true, [[t('shared.admin_filter.only'), 1], [t('shared.admin_filter.none'), 0]], { include_blank: t('shared.admin_filter.all'), selected: params[:q] ? params[:q][:platform_admin_true] : '' }
.table-responsive
  table.table.mt-4
    thead
      tr
        th = t('activerecord.attributes.internal_user.name')
        th = t('activerecord.attributes.internal_user.consumer')
        - if current_user.admin?
          th = t('activerecord.attributes.internal_user.platform_admin')
        th colspan=3 = t('shared.actions')
    tbody
      - @users.each do |user|
        tr
          td = link_to_if(policy(user).show?, user.name, user)
          td = user.consumer ? link_to_if(user.consumer.present? && policy(user.consumer).show?, user.consumer, user.consumer) : empty
          - if current_user.admin?
            td = symbol_for(user.platform_admin?)
          td = link_to(t('shared.show'), user) if policy(user).show?
          td = link_to(t('shared.edit'), edit_internal_user_path(user)) if policy(user).edit?
          td = link_to(t('shared.destroy'), user, data: {confirm: t('shared.confirm_destroy')}, method: :delete) if policy(user).destroy?

= render('shared/pagination', collection: @users)
p = render('shared/new_button', model: InternalUser)
