- Add orders index action to OrdersController with pagination support - Simplify dashboard to focus on user orders and actions - Redesign order show page with improved layout and ticket access - Remove complex event metrics in favor of streamlined order management - Add direct links to ticket downloads and better order navigation - Improve responsive design and user experience across order views 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.7 KiB
Ruby
Executable File
49 lines
1.7 KiB
Ruby
Executable File
# Controller for static pages and user dashboard
|
|
# Handles basic page rendering and user-specific content
|
|
class PagesController < ApplicationController
|
|
before_action :authenticate_user!, only: [ :dashboard ]
|
|
|
|
# Homepage showing featured events
|
|
#
|
|
# Display homepage with featured events and incoming ones
|
|
def home
|
|
@featured_events = Event.published.featured.limit(3)
|
|
|
|
if user_signed_in?
|
|
redirect_to(dashboard_path)
|
|
end
|
|
end
|
|
|
|
# User dashboard showing personalized content
|
|
# Accessible only to authenticated users
|
|
def dashboard
|
|
# User's orders with associated data
|
|
@user_orders = current_user.orders.includes(:event, tickets: :ticket_type)
|
|
.where(status: [ "paid", "completed" ])
|
|
.order(created_at: :desc)
|
|
.limit(10)
|
|
|
|
# Draft orders that can be retried
|
|
@draft_orders = current_user.orders.includes(tickets: [ :ticket_type, :event ])
|
|
.can_retry_payment
|
|
.order(:expires_at)
|
|
|
|
# Simplified upcoming events preview - only show if user has orders
|
|
if @user_orders.any?
|
|
ordered_event_ids = @user_orders.map(&:event).map(&:id)
|
|
@upcoming_preview_events = Event.published
|
|
.upcoming
|
|
.where.not(id: ordered_event_ids)
|
|
.order(start_time: :asc)
|
|
.limit(6)
|
|
else
|
|
@upcoming_preview_events = []
|
|
end
|
|
end
|
|
|
|
# Events page showing all published events with pagination
|
|
def events
|
|
@events = Event.published.order(created_at: :desc).page(params[:page])
|
|
end
|
|
end
|