<% content_for(:title, "Code de réduction #{@promotion_code.code} - #{@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', path: promoter_event_promotion_codes_path(@event) }, { name: @promotion_code.code } ] %>
<%= link_to promoter_event_promotion_codes_path(@event), class: "text-gray-400 hover:text-gray-600 transition-colors" do %> <% end %>

Détails du code de réduction

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

Informations du code

Code
<%= @promotion_code.code %>
Statut
<% 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 %>
Montant de la réduction
<%= number_to_currency(@promotion_code.discount_amount_cents / 100.0, unit: "€") %>
Événement
<%= link_to @event.name, promoter_event_path(@event), class: "text-purple-600 hover:text-purple-800" %>

Statistiques d'utilisation

<%= @promotion_code.uses_count %>
Utilisations
<% if @promotion_code.usage_limit %> <%= @promotion_code.usage_limit - @promotion_code.uses_count %> <% else %> ∞ <% end %>
Restants
<%= @promotion_code.orders.count %>
Commandes
<%= number_to_currency(@promotion_code.orders.sum(:total_amount_cents) / 100.0, unit: "€") %>
Montant total
<% if @promotion_code.orders.any? %>

Commandes utilisant ce code

<% @promotion_code.orders.includes(:user).order(created_at: :desc).limit(5).each do |order| %>
Commande #<%= order.id %>
<%= order.user.email %> • <%= l(order.created_at, format: :short) %>
<%= number_to_currency(order.total_amount_cents / 100.0, unit: "€") %>
<%= order.status %>
<% end %> <% if @promotion_code.orders.count > 5 %>
Et <%= @promotion_code.orders.count - 5 %> autres commandes...
<% end %>
<% end %>

Informations supplémentaires

Créé par

<%= @promotion_code.user.email %>

Créé le

<%= l(@promotion_code.created_at, format: :long) %>

Modifié le

<%= l(@promotion_code.updated_at, format: :long) %>

<% if @promotion_code.expires_at %>
Date d'expiration

<%= l(@promotion_code.expires_at, format: :long) %>

<% else %>
Date d'expiration

Jamais

<% end %>

Actions

<%= link_to edit_promoter_event_promotion_code_path(@event, @promotion_code), class: "w-full inline-flex items-center justify-center px-4 py-3 bg-gray-900 text-white font-medium rounded-lg hover:bg-gray-800 transition-colors duration-200" do %> Modifier <% 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: "w-full inline-flex items-center justify-center px-4 py-3 text-red-600 font-medium rounded-lg hover:bg-red-50 transition-colors duration-200" do %> Supprimer <% end %> <% end %> <%= link_to promoter_event_promotion_codes_path(@event), class: "w-full inline-flex items-center justify-center px-4 py-3 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition-colors duration-200" do %> Retour à la liste <% end %>