Skip to content

Commit

Permalink
Close #2216 create event api for organizer dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
phana25 committed Jan 10, 2025
1 parent 4ebd9f9 commit 3ae9cce
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
37 changes: 37 additions & 0 deletions app/controllers/spree/api/v2/organizer/events_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Spree
module Api
module V2
module Organizer
class EventsController < ::Spree::Api::V2::Organizer::BaseController
def index
collection = Spree::Taxon.where(vendor_id: params[:vendor_id])
.page(params[:page])
.per(params[:per_page])
render_serialized_payload do
serialize_collection.new(
collection,
collection_options(collection)
).serializable_hash
end
end

def show
resource = Spree::Taxon.find(params[:id])
render_serialized_payload { serialize_resource(resource) }
end

def serialize_resource(resource)
Spree::V2::Organizer::EventSerializer.new(
resource,
include: resource_includes
).serializable_hash
end

def serialize_collection
::Spree::V2::Organizer::EventSerializer
end
end
end
end
end
end
14 changes: 14 additions & 0 deletions app/serializers/spree/v2/organizer/event_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Spree
module V2
module Organizer
class EventSerializer < BaseSerializer
attributes :name, :subtitle, :from_date, :to_date, :description, :vendor_id, :permalink

has_one :category_icon, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer
has_one :app_banner, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer
has_one :web_banner, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer
has_one :home_banner, serializer: ::SpreeCmCommissioner::V2::Storefront::AssetSerializer
end
end
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
end

namespace :organizer do
resources :events
resources :tickets
end

Expand Down

0 comments on commit 3ae9cce

Please sign in to comment.