h1 = @user.displayname

= row(label: 'external_user.name', value: @user.name)
= row(label: 'external_user.email', value: @user.email) if current_user.admin?
= row(label: 'external_user.external_id') do
  code
    = @user.external_id
= row(label: 'external_user.consumer', value: link_to_if(@user.consumer.present? && policy(@user.consumer).show?, @user.consumer, @user.consumer))
= row(label: 'external_user.platform_admin', value: @user.platform_admin?) if current_user.admin?
= row(label: 'users.show.study_groups') do
  - visible_memberships = @user.study_group_memberships.select { |study_group_membership| policy(study_group_membership.study_group).show? }
  - if visible_memberships.any?
    ul.mb-0 class="#{visible_memberships.one? ? 'single_entry_inline_list' : 'inline_list'}"
      - visible_memberships = visible_memberships.sort_by{ |study_group_membership| study_group_membership.study_group.name}
      - visible_memberships.each do |study_group_membership|
        li
          => link_to(study_group_membership.study_group.name, study_group_membership.study_group)
          | (
          = t("activerecord.attributes.study_group_membership.role_type.#{study_group_membership.role}")
          // Only platform admins are allowed to take a shorthand and switch their study group.
          - if @user == current_user && current_user.admin? && study_group_membership.role_teacher?
            | ,
            - if study_group_membership.study_group_id == current_user.current_study_group_id
              span.text-success =< t('users.show.current_study_group')
            - else
              =< link_to(t('users.show.set_as_current_study_group'), set_as_current_study_group_path(study_group_membership.study_group), method: :post, class: 'text-body-secondary')
          - elsif @user == current_user && study_group_membership.role_teacher? && study_group_membership.study_group_id == current_user.current_study_group_id
            | ,
            span.text-success =< t('users.show.current_study_group')
          | )
  - else
    = t('users.show.no_groups')

h4.mt-4 = link_to(t('.exercise_statistics'), statistics_external_user_path(@user)) if policy(@user).statistics?

- if current_user.admin?
  h4.mt-4 = t('.tag_statistics')
  #loading data-user-id=@user.id
    .spinner
    = t('.loading_tag_statistics')
  #no-elements
    = t('.empty_tag_statistics')
  #tag-grid
