- content_for :page_title do
  = @tag.formatted_name

- content_for :heading_actions do
  - if current_user.can?(:view_dashboard)
    .time-period
      = date_range(@time_period)

  = link_to t('admin.tags.open'), tag_url(@tag), class: 'button', target: '_blank', rel: 'noopener noreferrer'

- if current_user.can?(:view_dashboard)
  .dashboard
    .dashboard__item
      = react_admin_component :counter,
                              end_at: @time_period.last,
                              href: tag_url(@tag),
                              label: t('admin.trends.tags.dashboard.tag_accounts_measure'),
                              measure: 'tag_accounts',
                              params: { id: @tag.id },
                              rel: 'noopener noreferrer',
                              start_at: @time_period.first,
                              target: '_blank'
    .dashboard__item
      = react_admin_component :counter,
                              end_at: @time_period.last,
                              label: t('admin.trends.tags.dashboard.tag_uses_measure'),
                              measure: 'tag_uses',
                              params: { id: @tag.id },
                              start_at: @time_period.first
    .dashboard__item
      = react_admin_component :counter,
                              end_at: @time_period.last,
                              label: t('admin.trends.tags.dashboard.tag_servers_measure'),
                              measure: 'tag_servers',
                              params: { id: @tag.id },
                              start_at: @time_period.first
    .dashboard__item
      = react_admin_component :dimension,
                              dimension: 'tag_servers',
                              end_at: @time_period.last,
                              label: t('admin.trends.tags.dashboard.tag_servers_dimension'),
                              limit: 8,
                              params: { id: @tag.id },
                              start_at: @time_period.first
    .dashboard__item
      = react_admin_component :dimension,
                              dimension: 'tag_languages',
                              end_at: @time_period.last,
                              label: t('admin.trends.tags.dashboard.tag_languages_dimension'),
                              limit: 8,
                              params: { id: @tag.id },
                              start_at: @time_period.first
    .dashboard__item
      = link_to admin_tag_path(@tag.id), class: ['dashboard__quick-access', @tag.usable? ? 'positive' : 'negative'] do
        - if @tag.usable?
          %span= t('admin.trends.tags.usable')
          = material_symbol 'check'
        - else
          %span= t('admin.trends.tags.not_usable')
          = material_symbol 'lock'

      = link_to admin_tag_path(@tag.id), class: ['dashboard__quick-access', @tag.trendable? ? 'positive' : 'negative'] do
        - if @tag.trendable?
          %span= t('admin.trends.tags.trendable')
          = material_symbol 'check'
        - else
          %span= t('admin.trends.tags.not_trendable')
          = material_symbol 'lock'

      = link_to admin_tag_path(@tag.id), class: ['dashboard__quick-access', @tag.listable? ? 'positive' : 'negative'] do
        - if @tag.listable?
          %span= t('admin.trends.tags.listable')
          = material_symbol 'check'
        - else
          %span= t('admin.trends.tags.not_listable')
          = material_symbol 'lock'

  %hr.spacer/

= simple_form_for @tag, url: admin_tag_path(@tag.id) do |f|
  = render 'shared/error_messages', object: @tag

  .fields-group
    = f.input :display_name, wrapper: :with_block_label

  .fields-group
    = f.input :usable, as: :boolean, wrapper: :with_label
    = f.input :trendable, as: :boolean, wrapper: :with_label
    = f.input :listable, as: :boolean, wrapper: :with_label

  .actions
    = f.button :button, t('generic.save_changes'), type: :submit
