diff --git a/app/assets/stylesheets/application.postcss.css b/app/assets/stylesheets/application.postcss.css index 0b0fcf5..fbd7944 100755 --- a/app/assets/stylesheets/application.postcss.css +++ b/app/assets/stylesheets/application.postcss.css @@ -13,3 +13,16 @@ /* Import pages */ @import "pages/home"; + +/* QR Code Styles */ +.qr-code-container { + @apply flex items-center justify-center; +} + +.qr-code-container svg { + max-width: 100% !important; + max-height: 100% !important; + width: 208px !important; + height: 208px !important; + display: block !important; +} diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 60b1763..704e2bd 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -3,7 +3,7 @@ # This controller now primarily handles legacy redirects and backward compatibility # Most ticket creation functionality has been moved to OrdersController class TicketsController < ApplicationController - before_action :authenticate_user!, only: [ :payment_success, :payment_cancel, :show, :download_ticket ] + before_action :authenticate_user!, only: [ :payment_success, :payment_cancel, :show, :ticket_view, :download_ticket ] before_action :set_event, only: [ :checkout, :retry_payment ] @@ -59,6 +59,23 @@ class TicketsController < ApplicationController redirect_to dashboard_path, alert: "Billet non trouvé" end + # Display ticket in PDF-like format + def ticket_view + @ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user).find_by( + tickets: { id: params[:ticket_id] }, + orders: { user_id: current_user.id } + ) + + if @ticket.nil? + redirect_to dashboard_path, alert: "Billet non trouvé ou vous n'avez pas l'autorisation d'accéder à ce billet" + return + end + + @event = @ticket.event + rescue ActiveRecord::RecordNotFound + redirect_to dashboard_path, alert: "Billet non trouvé" + end + # Download PDF ticket - only accessible by ticket owner # User must be authenticated to download ticket # TODO: change ID to an unique identifier (UUID) diff --git a/app/views/tickets/show.html.erb b/app/views/tickets/show.html.erb index 203c55d..b22a0c6 100644 --- a/app/views/tickets/show.html.erb +++ b/app/views/tickets/show.html.erb @@ -1,46 +1,46 @@ -
ID: #<%= @ticket.id %>
<%= @event.name %>
+ +<%= @event.name %>
<%= @ticket.ticket_type.name %>
-<%= @ticket.ticket_type.description %>
+ +<%= @ticket.ticket_type.name %>
+<%= @ticket.ticket_type.description %>
+ +
<%= number_to_currency(@ticket.price_euros, unit: "€", separator: ",", delimiter: " ", format: "%n %u") %>
<%= @ticket.first_name %>
+ +<%= @ticket.first_name %>
<%= @ticket.last_name %>
+ +<%= @ticket.last_name %>
<%= @ticket.created_at.strftime("%d %B %Y à %H:%M") %>
+ +<%= @ticket.created_at.strftime("%d %B %Y à %H:%M") %>
<%= @ticket.qr_code %>
+<%= @ticket.qr_code[0..7]... %>
+Scannez ce code à l'entrée
QR: <%= @ticket.qr_code[0..7] %>...
+Ce billet est valide pour une seule entrée.
+Présentez ce billet à l'entrée du lieu.
++ Généré le <%= Time.current.strftime('%d %B %Y à %H:%M') %> +
+