feat: Refactor cart storage to use API architecture

Move store_cart functionality from main EventsController to API namespace:
- Add store_cart method to Api::V1::EventsController with API key bypass
- Remove store_cart from main EventsController
- Update routes to use RESTful API endpoint structure
- Maintain session-based cart storage for frontend compatibility
This commit is contained in:
kbe
2025-08-30 20:12:50 +02:00
parent 6ea3005a65
commit b493027c86
5 changed files with 56 additions and 48 deletions

View File

@@ -10,7 +10,7 @@ class PagesController < ApplicationController
@events = Event.published.featured.limit(3)
if user_signed_in?
return redirect_to(dashboard_path)
redirect_to(dashboard_path)
end
end
@@ -25,14 +25,14 @@ class PagesController < ApplicationController
# User's booked events
@user_booked_events = Event.joins(ticket_types: :tickets)
.where(tickets: { user: current_user, status: 'active' })
.distinct
.limit(5)
.where(tickets: { user: current_user, status: "active" })
.distinct
.limit(5)
# Events sections
@today_events = Event.published.where("DATE(start_time) = ?", Date.current).order(start_time: :asc)
@tomorrow_events = Event.published.where("DATE(start_time) = ?", Date.current + 1).order(start_time: :asc)
@other_events = Event.published.upcoming.where.not("DATE(start_time) IN (?)", [Date.current, Date.current + 1]).order(start_time: :asc).page(params[:page])
@other_events = Event.published.upcoming.where.not("DATE(start_time) IN (?)", [ Date.current, Date.current + 1 ]).order(start_time: :asc).page(params[:page])
end
# Events page showing all published events with pagination