I added the features for users to use promotion code and for promoters to create on their events. May be rewrite to discount code?
109 lines
6.1 KiB
Plaintext
109 lines
6.1 KiB
Plaintext
<% content_for(:title, "Modifier le code de réduction - #{@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: "Modifier #{@promotion_code.code}" }
|
|
] %>
|
|
|
|
<div class="max-w-2xl 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">Modifier le 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>
|
|
|
|
<%= 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? %>
|
|
<div class="bg-red-50 border border-red-200 rounded-2xl p-4 mb-6">
|
|
<div class="flex items-start">
|
|
<i data-lucide="alert-circle" class="w-5 h-5 text-red-400 mr-3 mt-0.5 flex-shrink-0"></i>
|
|
<div class="flex-1">
|
|
<h3 class="text-sm font-medium text-red-800 mb-2">
|
|
<%= pluralize(@promotion_code.errors.count, "erreur") %> ont empêché ce code de réduction d'être sauvegardé :
|
|
</h3>
|
|
<ul class="list-disc list-inside text-sm text-red-700">
|
|
<% @promotion_code.errors.full_messages.each do |message| %>
|
|
<li><%= message %></li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="space-y-6">
|
|
<div>
|
|
<%= 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." %>
|
|
<p class="text-sm text-gray-500 mt-2">Ce code sera visible par les clients lors du paiement</p>
|
|
</div>
|
|
|
|
<div>
|
|
<%= form.label :discount_amount_euros, "Montant de la réduction (en euros)", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
|
<%= form.number_field :discount_amount_euros, 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) %>
|
|
<p class="text-sm text-gray-500 mt-2">Entrez le montant en euros (ex: 10, 5.50, 25)</p>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div>
|
|
<%= 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" %>
|
|
<p class="text-sm text-gray-500 mt-2">Laissez vide pour une durée illimitée</p>
|
|
</div>
|
|
|
|
<div>
|
|
<%= 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 %>
|
|
<p class="text-sm text-gray-500 mt-2">Laissez vide pour une utilisation illimitée</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
|
<div class="flex items-center">
|
|
<%= 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" %>
|
|
</div>
|
|
<div class="text-sm text-gray-500">
|
|
Les clients peuvent utiliser ce code de réduction
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
|
<div class="flex items-start">
|
|
<i data-lucide="info" class="w-5 h-5 text-blue-400 mr-3 mt-0.5 flex-shrink-0"></i>
|
|
<div>
|
|
<h4 class="text-sm font-medium text-blue-800 mb-1">Statut actuel</h4>
|
|
<div class="text-sm text-blue-700">
|
|
<p>Utilisations: <%= @promotion_code.uses_count %><%= " / #{@promotion_code.usage_limit}" if @promotion_code.usage_limit %></p>
|
|
<p>Commandes associées: <%= @promotion_code.orders.count %></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center justify-between pt-6 mt-8 border-t border-gray-200">
|
|
<%= 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 %>
|
|
<i data-lucide="x" class="w-4 h-4 mr-2"></i>
|
|
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" %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div> |