- Changed discount amount input from cents to euros in new and edit forms - Added decimal support with step="0.01" for precise euro amounts - Updated form labels and help text to reflect euro display - Added value conversion from stored cents to euros for editing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
212 lines
9.7 KiB
Plaintext
212 lines
9.7 KiB
Plaintext
<% content_for(:title, "Code de réduction #{@promotion_code.code} - #{@event.name}") %>
|
|
|
|
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
|
|
<!-- Breadcrumb -->
|
|
<%= 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 }
|
|
] %>
|
|
|
|
<div class="max-w-4xl mx-auto">
|
|
<div class="mb-8">
|
|
<div class="flex items-center space-x-4 mb-4">
|
|
<%= link_to promoter_event_promotion_codes_path(@event), class: "text-gray-400 hover:text-gray-600 transition-colors" do %>
|
|
<i data-lucide="arrow-left" class="w-5 h-5"></i>
|
|
<% end %>
|
|
<div class="flex-1">
|
|
<h1 class="text-3xl font-bold text-gray-900 mb-2">Détails du code de réduction</h1>
|
|
<p class="text-gray-600">
|
|
<code class="bg-gray-100 px-2 py-1 rounded text-sm"><%= @promotion_code.code %></code> pour <%= link_to @event.name, promoter_event_path(@event), class: "text-purple-600 hover:text-purple-800" %>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 lg:gap-8">
|
|
<!-- Main content -->
|
|
<div class="lg:col-span-2 space-y-6 lg:space-y-8">
|
|
<!-- Code details -->
|
|
<div class="bg-white rounded-2xl border border-gray-200 p-6">
|
|
<h3 class="text-lg font-semibold text-gray-900 mb-6">Informations du code</h3>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div>
|
|
<div class="text-sm text-gray-500 mb-2">Code</div>
|
|
<div class="text-lg font-semibold bg-gray-100 px-3 py-2 rounded-lg font-mono">
|
|
<%= @promotion_code.code %>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="text-sm text-gray-500 mb-2">Statut</div>
|
|
<div>
|
|
<% if @promotion_code.active? && (promotion_code.expires_at.nil? || promotion_code.expires_at > Time.current) %>
|
|
<span class="inline-flex px-3 py-1 text-sm font-semibold rounded-full bg-green-100 text-green-800">
|
|
<i data-lucide="check-circle" class="w-4 h-4 mr-1"></i>
|
|
Actif
|
|
</span>
|
|
<% elsif @promotion_code.expires_at && @promotion_code.expires_at <= Time.current %>
|
|
<span class="inline-flex px-3 py-1 text-sm font-semibold rounded-full bg-red-100 text-red-800">
|
|
<i data-lucide="x-circle" class="w-4 h-4 mr-1"></i>
|
|
Expiré
|
|
</span>
|
|
<% else %>
|
|
<span class="inline-flex px-3 py-1 text-sm font-semibold rounded-full bg-gray-100 text-gray-800">
|
|
<i data-lucide="pause-circle" class="w-4 h-4 mr-1"></i>
|
|
Inactif
|
|
</span>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="text-sm text-gray-500 mb-2">Montant de la réduction</div>
|
|
<div class="text-lg font-semibold text-green-600">
|
|
<%= number_to_currency(@promotion_code.discount_amount_cents / 100.0, unit: "€") %>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="text-sm text-gray-500 mb-2">Événement</div>
|
|
<div class="text-lg font-semibold">
|
|
<%= link_to @event.name, promoter_event_path(@event), class: "text-purple-600 hover:text-purple-800" %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Usage stats -->
|
|
<div class="bg-white rounded-2xl border border-gray-200 p-6">
|
|
<h3 class="text-lg font-semibold text-gray-900 mb-6">Statistiques d'utilisation</h3>
|
|
|
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
<div class="text-center p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-2xl font-bold text-gray-900">
|
|
<%= @promotion_code.uses_count %>
|
|
</div>
|
|
<div class="text-sm text-gray-500">Utilisations</div>
|
|
</div>
|
|
|
|
<div class="text-center p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-2xl font-bold text-blue-600">
|
|
<% if @promotion_code.usage_limit %>
|
|
<%= @promotion_code.usage_limit - @promotion_code.uses_count %>
|
|
<% else %>
|
|
∞
|
|
<% end %>
|
|
</div>
|
|
<div class="text-sm text-gray-500">Restants</div>
|
|
</div>
|
|
|
|
<div class="text-center p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-2xl font-bold text-purple-600">
|
|
<%= @promotion_code.orders.count %>
|
|
</div>
|
|
<div class="text-sm text-gray-500">Commandes</div>
|
|
</div>
|
|
|
|
<div class="text-center p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-2xl font-bold text-green-600">
|
|
<%= number_to_currency(@promotion_code.orders.sum(:total_amount_cents) / 100.0, unit: "€") %>
|
|
</div>
|
|
<div class="text-sm text-gray-500">Montant total</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Orders using this code -->
|
|
<% if @promotion_code.orders.any? %>
|
|
<div class="bg-white rounded-2xl border border-gray-200 p-6">
|
|
<h3 class="text-lg font-semibold text-gray-900 mb-4">Commandes utilisant ce code</h3>
|
|
<div class="space-y-3">
|
|
<% @promotion_code.orders.includes(:user).order(created_at: :desc).limit(5).each do |order| %>
|
|
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
|
|
<div>
|
|
<div class="font-medium text-gray-900">Commande #<%= order.id %></div>
|
|
<div class="text-sm text-gray-500">
|
|
<%= order.user.email %> • <%= l(order.created_at, format: :short) %>
|
|
</div>
|
|
</div>
|
|
<div class="text-right">
|
|
<div class="font-medium text-gray-900"><%= number_to_currency(order.total_amount_cents / 100.0, unit: "€") %></div>
|
|
<div class="text-sm text-gray-500"><%= order.status %></div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% if @promotion_code.orders.count > 5 %>
|
|
<div class="text-center pt-2">
|
|
<span class="text-sm text-gray-500">
|
|
Et <%= @promotion_code.orders.count - 5 %> autres commandes...
|
|
</span>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<!-- Sidebar -->
|
|
<div class="space-y-6">
|
|
<!-- Additional info -->
|
|
<div class="bg-white rounded-2xl border border-gray-200 p-6">
|
|
<h3 class="text-lg font-semibold text-gray-900 mb-4">Informations supplémentaires</h3>
|
|
<div class="space-y-4">
|
|
<div>
|
|
<span class="text-sm text-gray-500">Créé par</span>
|
|
<p class="text-sm font-medium"><%= @promotion_code.user.email %></p>
|
|
</div>
|
|
<div>
|
|
<span class="text-sm text-gray-500">Créé le</span>
|
|
<p class="text-sm"><%= l(@promotion_code.created_at, format: :long) %></p>
|
|
</div>
|
|
<div>
|
|
<span class="text-sm text-gray-500">Modifié le</span>
|
|
<p class="text-sm"><%= l(@promotion_code.updated_at, format: :long) %></p>
|
|
</div>
|
|
<% if @promotion_code.expires_at %>
|
|
<div>
|
|
<span class="text-sm text-gray-500">Date d'expiration</span>
|
|
<p class="text-sm"><%= l(@promotion_code.expires_at, format: :long) %></p>
|
|
</div>
|
|
<% else %>
|
|
<div>
|
|
<span class="text-sm text-gray-500">Date d'expiration</span>
|
|
<p class="text-sm">Jamais</p>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Actions -->
|
|
<div class="bg-white rounded-2xl border border-gray-200 p-6">
|
|
<h3 class="text-lg font-semibold text-gray-900 mb-4">Actions</h3>
|
|
<div class="space-y-3">
|
|
<%= 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 %>
|
|
<i data-lucide="edit" class="w-4 h-4 mr-2"></i>
|
|
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 %>
|
|
<i data-lucide="trash-2" class="w-4 h-4 mr-2"></i>
|
|
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 %>
|
|
<i data-lucide="arrow-left" class="w-4 h-4 mr-2"></i>
|
|
Retour à la liste
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> |