%tr{ id: dom_id(order), class: "state-#{order.state}" }
  %td.align-left
    %input{type: 'checkbox', value: order.id, name: 'bulk_ids[]', "data-checked-target": "checkbox" }
  %td.align-left
    = order.distributor.name
  %td.align-left
    = I18n.l(order.completed_at, format: '%B %d, %Y') if order.completed_at
  %td
    %a{ href: edit_admin_order_path(order) }
      = order.number
    - if order.special_instructions.present?
      %div
        %br
        %div{ "data-controller": "tooltip", "data-tooltip-tip-value": order.special_instructions.to_s }
          %span.icon-warning-sign{ "data-tooltip-target": "element" }
            = t('spree.admin.orders.index.note')
            .tooltip-container
              .tooltip{"data-tooltip-target": "tooltip"}
                = sanitize order.special_instructions.to_s
                .arrow{"data-tooltip-target": "arrow"}
  %td.align-left
    %span.state{ class: order.state.to_s }
      = t('js.admin.orders.order_state.' + order.state.to_s)
  %td.align-left
    - if order.payment_state
      %span.state{ class: order.payment_state.to_s }
        %a{href: spree.admin_order_payments_path(order) }
          = t('js.admin.orders.payment_states.' + order.payment_state.to_s)
          - if order.display_outstanding_balance
            %span
              = "(#{order.display_outstanding_balance})"
  %td.align-left
    - if order.shipment_state
      %span.state{ class: order.shipment_state.to_s}
        = t('js.admin.orders.shipment_states.' + order.shipment_state.to_s)
  %td
    %a{ href: "mailto:#{order.email}", target: "_blank" }
      = order.email
  %td
    = order&.bill_address&.full_name_for_sorting
  %td.align-left
    %span
      = order.display_total
  %td.actions
    .row-loading-icons
      - if local_assigns[:success]
        %i.success.icon-ok-sign{"data-controller": "ephemeral"}
    = render AdminTooltipComponent.new(text: t('spree.admin.orders.index.edit'), link_text: "", link: edit_admin_order_path(order), link_class: "icon_link with-tip icon-edit no-text")
    - if order.ready_to_ship?
      %form
        = render ShipOrderComponent.new(order: order)
      = render partial: 'admin/shared/tooltip_button', locals: {button_class: "icon-road icon_link with-tip no-text", reflex_data_id: order.id.to_s, tooltip_text: t('spree.admin.orders.index.ship'), shipment: true}

    - if order.payment_required? && order.pending_payments.reject(&:requires_authorization?).any?
      = render partial: 'admin/shared/tooltip_button', locals: {button_class: "icon-capture icon_link no-text", button_reflex: "click->Admin::OrdersReflex#capture", reflex_data_id: order.id.to_s,  tooltip_text: t('spree.admin.orders.index.capture')}
