<%= render 'shared/settings_nav' %>

<% if params[:status] == 'archived' %> <%= t('archived_users') %> <% elsif params[:status] == 'integration' %> <%= t('embedding_users') %> <% else %> <%= t('users') %> <% end %>

<% if params[:status].blank? && can?(:create, User.new(account: current_account)) %> <%= render 'users/extra_buttons' %> <% if content_for(:add_user_button) %> <%= content_for(:add_user_button) %> <% else %> <%= link_to new_user_path, class: 'btn btn-primary btn-md gap-2 w-full md:w-fit', data: { turbo_frame: 'modal' } do %> <%= svg_icon('plus', class: 'w-6 h-6') %> <%= t('new_user') %> <% end %> <% end %> <% end %>
<% @users.each do |user| %> <% end %>
<%= t('name') %> <%= t('email') %> <%= t('role') %> <%= t('last_session') %>
<%= user.full_name %> <%= user.email %> <%= t(user.role) %> <%= user.current_sign_in_at ? l(user.current_sign_in_at.in_time_zone(current_account.timezone), format: :short, locale: current_account.locale) : '-' %> <% if params[:status].blank? && can?(:update, user) && user.archived_at.blank? %> <%= link_to edit_user_path(user), class: 'btn btn-outline btn-xs', title: t('edit'), data: { turbo_frame: 'modal' } do %> <%= t('edit') %> <% end %> <% end %> <% if params[:status] != 'archived' && can?(:destroy, user) && user != current_user %> <%= button_to user_path(user), method: :delete, class: 'btn btn-outline btn-error btn-xs', title: t('remove'), data: { turbo_confirm: t('are_you_sure_') } do %> <%= t('remove') %> <% end %> <% end %> <% if params[:status] == 'archived' && can?(:manage, user) && user != current_user && user.archived_at? %> <%= button_to user_path(user), method: :put, params: { user: { archived_at: nil } }, class: 'btn btn-outline btn-xs', title: t('unarchive'), data: { turbo_confirm: t('are_you_sure_') } do %> <%= t('unarchive') %> <% end %> <% end %>
<% if @pagy.pages > 1 %> <%= render 'shared/pagination', pagy: @pagy, items_name: 'users', left_additional_html: render('bottom_links') %> <% else %>
<%= render 'bottom_links' %>
<% end %>