wip: order checkout

This commit is contained in:
kbe
2025-09-02 02:56:23 +02:00
parent afe074c8a1
commit ca81d2360c
18 changed files with 893 additions and 292 deletions

View File

@@ -31,8 +31,8 @@
</div>
</div>
<!-- Draft tickets needing payment -->
<% if @draft_tickets.any? %>
<!-- Draft orders needing payment -->
<% if @draft_orders.any? %>
<div class="card hover-lift mb-8 border-orange-200 bg-orange-50">
<div class="card-header bg-orange-100 rounded-lg">
@@ -41,40 +41,39 @@
<svg class="w-6 h-6 mr-2 text-orange-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
Billets en attente de paiement
Commandes en attente de paiement
</h2>
<p class="text-orange-700 mt-1">Vous avez des billets qui nécessitent un paiement</p>
<p class="text-orange-700 mt-1">Vous avez des commandes qui nécessitent un paiement</p>
</div>
</div>
<div class="card-body">
<div class="space-y-4">
<% @draft_tickets.group_by(&:event).each do |event, tickets| %>
<% @draft_orders.each do |order| %>
<div class="bg-white rounded-lg p-4 border border-orange-200">
<div class="flex items-start justify-between mb-3">
<div>
<h3 class="font-semibold text-gray-900"><%= event.name %></h3>
<h3 class="font-semibold text-gray-900"><%= order.event.name %></h3>
<p class="text-sm text-gray-600">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
<%= event.start_time.strftime("%d %B %Y à %H:%M") %>
<%= order.event.start_time.strftime("%d %B %Y à %H:%M") %>
</p>
</div>
<span class="text-sm font-medium text-orange-600 bg-orange-100 px-2 py-1 rounded-full">
<%= tickets.count %> billet<%= 's' if tickets.count > 1 %>
Commande #<%= order.id %>
</span>
</div>
<div class="grid gap-2 mb-4">
<% tickets.each do |ticket| %>
<% order.tickets.each do |ticket| %>
<div class="flex items-center justify-between text-sm bg-gray-50 rounded p-2">
<div>
<span class="font-medium"><%= ticket.ticket_type.name %></span>
<span class="text-gray-600">- <%= ticket.first_name %> <%= ticket.last_name %></span>
</div>
<div class="flex items-center space-x-2">
<span class="text-gray-600">Expire <%= time_ago_in_words(ticket.expires_at) %></span>
<span class="font-medium text-gray-900"><%= number_to_currency(ticket.price_euros, unit: "€") %></span>
</div>
</div>
@@ -83,17 +82,17 @@
<div class="flex items-center justify-between">
<div class="text-sm text-gray-600">
<% max_attempts = tickets.map(&:payment_attempts).max %>
Tentatives: <%= max_attempts %>/3
<% if tickets.any?(&:expiring_soon?) %>
<span class="text-orange-600 font-medium ml-2">⚠️ Expire bientôt</span>
Tentatives: <%= order.payment_attempts %>/3
<% if order.expiring_soon? %>
<span class="text-orange-600 font-medium ml-2">⚠️ Expire dans <%= time_ago_in_words(order.expires_at) %></span>
<% else %>
<span class="text-gray-500 ml-2">Expire dans <%= time_ago_in_words(order.expires_at) %></span>
<% end %>
</div>
<%= form_tag ticket_retry_payment_path(event.slug, event.id), method: :post do %>
<%= hidden_field_tag :ticket_ids, tickets.map(&:id).join(',') %>
<%= submit_tag "Reprendre le paiement",
class: "inline-flex items-center px-4 py-2 bg-orange-600 text-white text-sm font-medium rounded-lg hover:bg-orange-700 transition-colors duration-200" %>
<%= link_to retry_payment_order_path(order), method: :post,
class: "inline-flex items-center px-4 py-2 bg-orange-600 text-white text-sm font-medium rounded-lg hover:bg-orange-700 transition-colors duration-200" do %>
Reprendre le paiement (<%= order.total_amount_euros %>€)
<% end %>
</div>
</div>