I added the features for users to use promotion code and for promoters to create on their events. May be rewrite to discount code?
97 lines
5.3 KiB
Plaintext
97 lines
5.3 KiB
Plaintext
<% content_for(:title, "Nouveau 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: 'Nouveau 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">Nouveau code de réduction</h1>
|
|
<p class="text-gray-600">
|
|
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_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? %>
|
|
<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: BIENVENUE10, VIP20" %>
|
|
<p class="text-sm text-gray-500 mt-2">Ce code sera à appliquer par le client 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</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>
|
|
|
|
<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 "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" %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|