mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Move json to API and strip index action
This commit is contained in:
23
app/controllers/api/orders_controller.rb
Normal file
23
app/controllers/api/orders_controller.rb
Normal 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
|
||||
Reference in New Issue
Block a user