<div class="py-4 px-8 w-full space-y-3">
  <div class="flex space-x-4">
    <% if action.is_a?(Actions::TracksCreator) %>
      <div class="flex-0">
        <%= render "shared/memberships/photo", membership: action.created_by, size: 7 %>
      </div>
    <% end %>
    <div class="flex-1">
      <div class="flex">
        <div class="flex-1 space-y-4 py-1">
          <div>
            <%= action.label_string %> on
            <%= target_description = capture do %>
              <% if action.is_a?(Actions::TargetsMany) %>
                <% if action.target_all? %>
                  all Tangible Things
                <% else %>
                  <% if action.target_ids.one? %>
                    <%= action.targeted.first.label_string %>
                  <% else %>
                    <%= action.target_ids.count %> <%= "Tangible Thing".pluralize(action.target_ids.count) %>
                  <% end %>
                <% end %>
              <% else %>
                <%= action.targeted.label_string %>
              <% end %>
            <% end %>
          </div>
        </div>
        <div class="flex-0">
          <% if action.is_a?(Actions::RequiresApproval) %>
            <% if can? :approve, action %>
              <%= button_to t("#{action.class.name.pluralize.underscore}.buttons.shorthand.approve"), [:approve, :account, action], method: :post, class: 'button-secondary button-smaller' %>
            <% end %>
          <% end %>
          <% if can? :read, action %>
            <%= link_to t("#{action.class.name.pluralize.underscore}.buttons.shorthand.show"), [:account, action], class: 'button-secondary button-smaller' %>
          <% end %>
          <% if can? :edit, action %>
            <%= link_to t("#{action.class.name.pluralize.underscore}.buttons.shorthand.edit"), [:edit, :account, action], class: 'button-secondary button-smaller' %>
          <% end %>
          <% if can? :destroy, action %>
            <%= button_to t("#{action.class.name.pluralize.underscore}.buttons.shorthand.destroy"), [:account, action], method: :delete, data: { confirm: t("#{action.class.name.pluralize.underscore}.buttons.confirmations.destroy", model_locales(action)) }, class: 'button-secondary button-smaller' %>
          <% end %>
        </div>
      </div>

      <% if action.completed? %>
        <% if action.is_a?(Actions::HasProgress) %>
          <div class="uppercase text-xs text-gray-400">
            Processed <%= action.performed_count %> of <%= action.target_count %> <%= display_date_and_time(action.completed_at) %>
          </div>
        <% else %>
          <div class="uppercase text-xs text-gray-400">
            Processed <%= display_date_and_time(action.completed_at) %>
          </div>
        <% end %>

      <% elsif action.is_a?(Actions::RequiresApproval) && !action.approved? %>
        <div class="uppercase text-xs text-gray-400">
          Awaiting approval
        </div>

      <% elsif action.is_a?(Actions::SupportsScheduling) && action.scheduled_for && !action.started? %>
        <div class="uppercase text-xs text-gray-400">
          Scheduled for <%= display_date_and_time(action.scheduled_for) %>
        </div>

      <% elsif action.is_a?(Actions::HasProgress) && action.started? %>
        <div class="mt-3 h-4 bg-gray-100 shadow-inner rounded w-full">
          <div class="h-4 animate-pulse bg-primary-500 rounded" style="width: <%= action.completion_percent %>%"></div>
        </div>

        <div class="mt-2 uppercase text-xs text-gray-400">
          Processing <%= action.performed_count %> of <%= action.target_count %>
        </div>

      <% elsif action.is_a?(Actions::HasProgress) %>
        <div class="uppercase text-xs text-gray-400">
          Preparing to process <%= action.performed_count %> of <%= action.target_count %>
        </div>

      <% else %>
        <div class="uppercase text-xs text-gray-400">
          Preparing to process
        </div>

      <% end %>
    </div>
  </div>
</div>