Move json to API and strip index action

This commit is contained in:
Matt-Yorkley
2018-10-23 10:34:42 +01:00
parent 0bd67bd06a
commit 334eebeab1
4 changed files with 27 additions and 15 deletions

View File

@@ -0,0 +1,23 @@
module Api
class OrdersController < BaseController
def index
authorize! :admin, Spree::Order
search_results = SearchOrders.new(params, spree_current_user)
render json: {
orders: serialized_orders(search_results.orders),
pagination: search_results.pagination_data
}
end
private
def serialized_orders(orders)
ActiveModel::ArraySerializer.new(
orders,
each_serializer: Api::Admin::OrderSerializer
)
end
end
end