<div class="card bg-light mb-3 ">
  <div class="card-header">
    <%= condition.class.model_name.human %>
    <span class="float-right">
      <% if can?(:destroy, condition) %>
        <%= link_to_with_icon 'trash', '', solidus_promotions.admin_promotion_benefit_condition_path(@promotion, condition.benefit, condition), method: :delete, class: 'delete' %>
      <% end %>
    </span>
  </div>
  <div class="card-body">
    <%= form_with model: condition, scope: :condition, url: solidus_promotions.admin_promotion_benefit_condition_path(@promotion, condition.benefit, condition), method: :patch do |form| %>
      <% param_prefix = "promotion[conditions_attributes][#{condition.id}]" %>
      <%= hidden_field_tag "#{param_prefix}[id]", condition.id %>
      <%= render partial: "spree/shared/error_messages", locals: { target: condition } %>
      <%= render condition, condition: condition, param_prefix: "condition", form: form %>

      <% if condition.updateable? %>
        <div class="row">
          <div class="col-12">
            <%= form.submit(t(:update, scope: [:solidus_promotions, :crud]), class: "btn btn-secondary float-right") %>
          </div>
        </div>
      <% end %>
    <% end %>
  </div>
</div>
