wip: OrdersController#new
This commit is contained in:
@@ -62,6 +62,7 @@ module Api
|
||||
def store_cart
|
||||
cart_data = params[:cart] || {}
|
||||
session[:pending_cart] = cart_data
|
||||
session[:event_id] = @event.id
|
||||
|
||||
render json: { status: "success", message: "Cart stored successfully" }
|
||||
rescue => e
|
||||
|
||||
@@ -6,7 +6,31 @@ class OrdersController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :set_order, only: [:show, :checkout, :retry_payment, :increment_payment_attempt]
|
||||
|
||||
# Display new order form
|
||||
#
|
||||
# On this page user can complete the tickets details (first name and last name),
|
||||
# add a comment on the order.
|
||||
def new
|
||||
@cart_data = session[:pending_cart] || {}
|
||||
|
||||
if @cart_data.empty?
|
||||
redirect_to root_path, alert: "Veuillez d'abord sélectionner vos billets"
|
||||
return
|
||||
end
|
||||
|
||||
# Build order preview from cart data
|
||||
@event_id = session[:event_id]
|
||||
if @event_id.present?
|
||||
@event = Event.includes(:ticket_types).find_by(id: @event_id)
|
||||
redirect_to root_path, alert: "Événement non trouvé" unless @event
|
||||
else
|
||||
redirect_to root_path, alert: "Informations manquantes"
|
||||
end
|
||||
end
|
||||
|
||||
# Display order summary
|
||||
#
|
||||
#
|
||||
def show
|
||||
@tickets = @order.tickets.includes(:ticket_type)
|
||||
end
|
||||
@@ -115,7 +139,7 @@ class OrdersController < ApplicationController
|
||||
|
||||
if order_id.present?
|
||||
order = current_user.orders.find_by(id: order_id, status: "draft")
|
||||
|
||||
|
||||
if order&.can_retry_payment?
|
||||
redirect_to order_checkout_path(order),
|
||||
alert: "Le paiement a été annulé. Vous pouvez réessayer."
|
||||
@@ -163,4 +187,4 @@ class OrdersController < ApplicationController
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Controller for static pages and user dashboard
|
||||
# Handles basic page rendering and user-specific content
|
||||
class PagesController < ApplicationController
|
||||
# Skip authentication for public pages
|
||||
# skip_before_action :authenticate_user!, only: [ :home ]
|
||||
before_action :authenticate_user!, only: [ :dashboard ]
|
||||
|
||||
# Homepage showing featured events
|
||||
#
|
||||
# Display homepage with featured events and incoming ones
|
||||
def home
|
||||
@events = Event.published.featured.limit(3)
|
||||
@featured_events = Event.published.featured.limit(3)
|
||||
|
||||
if user_signed_in?
|
||||
redirect_to(dashboard_path)
|
||||
|
||||
Reference in New Issue
Block a user