<% content_for(:title, "Codes de réduction - #{@event.name}") %>
<%= render 'components/breadcrumb', crumbs: [ { name: 'Accueil', path: root_path }, { name: 'Tableau de bord', path: dashboard_path }, { name: 'Mes événements', path: promoter_events_path }, { name: @event.name, path: promoter_event_path(@event) }, { name: 'Codes de réduction' } ] %>
<%= link_to promoter_event_path(@event), class: "text-gray-400 hover:text-gray-600 transition-colors" do %> <% end %>

Codes de réduction

<%= link_to @event.name, promoter_event_path(@event), class: "text-purple-600 hover:text-purple-800" %>

<%= link_to new_promoter_event_promotion_code_path(@event), class: "inline-flex items-center px-6 py-3 bg-gray-900 text-white font-medium rounded-lg hover:bg-gray-800 transition-colors duration-200" do %> Nouveau code <% end %>
<% if @event.draft? %>

Cet événement est en brouillon. Les codes de réduction ne seront actifs qu'une fois l'événement publié.

<% end %>
<% if @promotion_codes.any? %>
<% @promotion_codes.each do |promotion_code| %>

<%= promotion_code.code %>

Réduction de <%= number_to_currency(promotion_code.discount_amount_cents / 100.0, unit: "€") %>

<% if promotion_code.active? && (promotion_code.expires_at.nil? || promotion_code.expires_at > Time.current) %> Actif <% elsif promotion_code.expires_at && promotion_code.expires_at <= Time.current %> Expiré <% else %> Inactif <% end %>
<%= number_to_currency(promotion_code.discount_amount_cents / 100.0, unit: "€") %>
Réduction
<% if promotion_code.usage_limit %> <%= promotion_code.usage_limit - promotion_code.uses_count %> <% else %> ∞ <% end %>
Restants
<%= promotion_code.uses_count %>
Utilisés
<%= promotion_code.orders.count %>
Commandes
<% if promotion_code.expires_at %> Expire le : <%= l(promotion_code.expires_at, format: :short) %> <% else %> Pas d'expiration <% end %> <% if promotion_code.user.first_name && promotion_code.user.last_name %> Créé par : <%= promotion_code.user.first_name %> <%= promotion_code.user.last_name %> <% else %> Créé par : <%= promotion_code.user.email %> <% end %>
<%= link_to edit_promoter_event_promotion_code_path(@event, promotion_code), class: "text-gray-400 hover:text-blue-600 transition-colors", title: "Modifier" do %> <% end %> <% if promotion_code.orders.empty? %> <%= button_to promoter_event_promotion_code_path(@event, promotion_code), method: :delete, data: { confirm: "Êtes-vous sûr de vouloir supprimer ce code de réduction ?" }, class: "text-gray-400 hover:text-red-600 transition-colors", title: "Supprimer" do %> <% end %> <% end %>
Créé il y a <%= time_ago_in_words(promotion_code.created_at) %>
<% end %>
<% else %>

Aucun code de réduction

Créez des codes de réduction pour offrir des remises spéciales à vos clients.

<%= link_to new_promoter_event_promotion_code_path(@event), class: "inline-flex items-center px-6 py-3 bg-gray-900 text-white font-medium rounded-lg hover:bg-gray-800 transition-colors duration-200" do %> Créer mon premier code de réduction <% end %>
<% end %>