<% admin_breadcrumb link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path %>
<% admin_breadcrumb link_to(@promotion.name, solidus_promotions.edit_admin_promotion_path(@promotion)) %>
<% admin_breadcrumb plural_resource_name(SolidusPromotions::PromotionCode) %>

<% content_for :page_actions do %>
  <li>
    <% if can?(:create, SolidusPromotions::PromotionCode) && !@promotion.apply_automatically? %>
      <%= link_to t('solidus_promotions.create_promotion_code'), solidus_promotions.new_admin_promotion_promotion_code_path(promotion_id: @promotion.id), class: 'btn btn-primary' %>
    <% end %>

    <%= link_to t('solidus_promotions.download_promotion_codes_list'), solidus_promotions.admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv), class: 'btn btn-primary' %>
  </li>
<% end %>

<div class="pagination-summary">
  <%= page_entries_info(@promotion_codes) %>
</div>

<table>
  <thead>
    <th><%= SolidusPromotions::PromotionCode.human_attribute_name :value %></th>
  </thead>
  <tbody>
    <% @promotion_codes.each do |promotion_code| %>
      <tr>
        <td><%= promotion_code.value %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= paginate @promotion_codes, theme: "solidus_admin" %>
