diff --git a/app/views/promoter/promotion_codes/edit.html.erb b/app/views/promoter/promotion_codes/edit.html.erb
new file mode 100644
index 0000000..cd90cdb
--- /dev/null
+++ b/app/views/promoter/promotion_codes/edit.html.erb
@@ -0,0 +1,109 @@
+<% content_for(:title, "Modifier le code 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', path: promoter_event_promotion_codes_path(@event) },
+ { name: "Modifier #{@promotion_code.code}" }
+ ] %>
+
+
+
+
+ <%= link_to promoter_event_promotion_codes_path(@event), class: "text-gray-400 hover:text-gray-600 transition-colors" do %>
+
+ <% end %>
+
+
Modifier le code de réduction
+
+ <%= @promotion_code.code %> pour <%= link_to @event.name, promoter_event_path(@event), class: "text-purple-600 hover:text-purple-800" %>
+
+
+
+
+
+ <%= form_with(model: [@event, @promotion_code], url: promoter_event_promotion_code_path(@event, @promotion_code), method: :patch, local: true, class: "bg-white rounded-2xl border border-gray-200 p-6 sm:p-8") do |form| %>
+ <% if @promotion_code.errors.any? %>
+
+
+
+
+
+ <%= pluralize(@promotion_code.errors.count, "erreur") %> ont empêché ce code de réduction d'être sauvegardé :
+
+
+ <% @promotion_code.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+
+
+ <% end %>
+
+
+
+ <%= form.label :code, "Code de réduction", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.text_field :code, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors", placeholder: "Ex: SUMMER2024, BIENVENUE10, etc." %>
+
Ce code sera visible par les clients lors du paiement
+
+
+
+ <%= form.label :discount_amount_cents, "Montant de la réduction (en euros)", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.number_field :discount_amount_cents, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors", placeholder: "10", min: 0, step: "0.01", value: number_with_precision(@promotion_code.discount_amount_cents.to_f / 100, precision: 2) %>
+
Entrez le montant en euros (ex: 10, 5.50, 25)
+
+
+
+
+ <%= form.label :expires_at, "Date d'expiration", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.datetime_local_field :expires_at, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors" %>
+
Laissez vide pour une durée illimitée
+
+
+
+ <%= form.label :usage_limit, "Limite d'utilisation", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.number_field :usage_limit, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors", placeholder: "Ex: 50", min: 1 %>
+
Laissez vide pour une utilisation illimitée
+
+
+
+
+
+ <%= form.check_box :active, class: "h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300 rounded" %>
+ <%= form.label :active, "Code actif", class: "ml-3 block text-sm font-medium text-gray-900" %>
+
+
+ Les clients peuvent utiliser ce code de réduction
+
+
+
+
+
+
+
+
Statut actuel
+
+
Utilisations: <%= @promotion_code.uses_count %><%= " / #{@promotion_code.usage_limit}" if @promotion_code.usage_limit %>
+
Commandes associées: <%= @promotion_code.orders.count %>
+
+
+
+
+
+
+
+ <%= link_to promoter_event_promotion_codes_path(@event), class: "inline-flex items-center px-6 py-3 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition-colors duration-200" do %>
+
+ Annuler
+ <% end %>
+ <%= form.submit "Mettre à jour le code de réduction", 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" %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/promoter/promotion_codes/index.html.erb b/app/views/promoter/promotion_codes/index.html.erb
new file mode 100644
index 0000000..ff57f9f
--- /dev/null
+++ b/app/views/promoter/promotion_codes/index.html.erb
@@ -0,0 +1,175 @@
+<% 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| %>
+
+
+
+
+
+
+
+ <%= link_to promotion_code.code, promoter_event_promotion_code_path(@event, promotion_code), class: "hover:text-purple-600 transition-colors" %>
+
+
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 %>
+
diff --git a/app/views/promoter/promotion_codes/new.html.erb b/app/views/promoter/promotion_codes/new.html.erb
new file mode 100644
index 0000000..039086b
--- /dev/null
+++ b/app/views/promoter/promotion_codes/new.html.erb
@@ -0,0 +1,96 @@
+<% content_for(:title, "Nouveau code 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', path: promoter_event_promotion_codes_path(@event) },
+ { name: 'Nouveau code' }
+ ] %>
+
+
+
+
+ <%= link_to promoter_event_promotion_codes_path(@event), class: "text-gray-400 hover:text-gray-600 transition-colors" do %>
+
+ <% end %>
+
+
Nouveau code de réduction
+
+ Pour <%= link_to @event.name, promoter_event_path(@event), class: "text-purple-600 hover:text-purple-800" %>
+
+
+
+
+
+ <%= form_with(model: [@event, @promotion_code], url: promoter_event_promotion_codes_path(@event), local: true, class: "bg-white rounded-2xl border border-gray-200 p-6 sm:p-8") do |form| %>
+ <% if @promotion_code.errors.any? %>
+
+
+
+
+
+ <%= pluralize(@promotion_code.errors.count, "erreur") %> ont empêché ce code de réduction d'être sauvegardé :
+
+
+ <% @promotion_code.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+
+
+ <% end %>
+
+
+
+ <%= form.label :code, "Code de réduction", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.text_field :code, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors", placeholder: "Ex: SUMMER2024, BIENVENUE10, etc." %>
+
Ce code sera visible par les clients lors du paiement
+
+
+
+ <%= form.label :discount_amount_cents, "Montant de la réduction (en euros)", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.number_field :discount_amount_cents, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors", placeholder: "10", min: 0, step: "0.01", value: number_with_precision(@promotion_code.discount_amount_cents.to_f / 100, precision: 2) %>
+
Entrez le montant en euros (ex: 10, 5.50, 25)
+
+
+
+
+ <%= form.label :expires_at, "Date d'expiration", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.datetime_local_field :expires_at, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors" %>
+
Laissez vide pour une durée illimitée
+
+
+
+ <%= form.label :usage_limit, "Limite d'utilisation", class: "block text-sm font-medium text-gray-700 mb-2" %>
+ <%= form.number_field :usage_limit, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors", placeholder: "Ex: 50", min: 1 %>
+
Laissez vide pour une utilisation illimitée
+
+
+
+
+
+ <%= form.check_box :active, class: "h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300 rounded" %>
+ <%= form.label :active, "Code actif", class: "ml-3 block text-sm font-medium text-gray-900" %>
+
+
+ Les clients peuvent utiliser ce code de réduction
+
+
+
+
+
+ <%= link_to promoter_event_promotion_codes_path(@event), class: "inline-flex items-center px-6 py-3 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition-colors duration-200" do %>
+
+ Annuler
+ <% end %>
+ <%= form.submit "Créer le code de réduction", 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" %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/promoter/promotion_codes/show.html.erb b/app/views/promoter/promotion_codes/show.html.erb
new file mode 100644
index 0000000..69f3789
--- /dev/null
+++ b/app/views/promoter/promotion_codes/show.html.erb
@@ -0,0 +1,212 @@
+<% 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 %>
+
+
+
+
+
+
\ No newline at end of file