mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move data fetching from injection helper to action
Data fetching is a controller action responsibility. We shouldn't couple the controller with it too much but it should trigger it, not the view-layer.
This commit is contained in:
@@ -15,6 +15,11 @@ module Spree
|
||||
# Ignores invoice orders, only order where state: 'complete'
|
||||
def show
|
||||
@orders = @user.orders.where(state: 'complete').order('completed_at desc')
|
||||
|
||||
customers = spree_current_user.customers
|
||||
@shops = Enterprise
|
||||
.where(id: @orders.pluck(:distributor_id).uniq | customers.pluck(:enterprise_id))
|
||||
|
||||
@unconfirmed_email = spree_current_user.unconfirmed_email
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
- content_for :injection_data do
|
||||
= inject_orders
|
||||
= inject_shops
|
||||
= inject_json_array("orders", @orders.all, Api::OrderSerializer)
|
||||
= inject_json_array("shops", @shops.all, Api::ShopForOrdersSerializer)
|
||||
= inject_saved_credit_cards
|
||||
|
||||
- if Stripe.publishable_key
|
||||
:javascript
|
||||
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
|
||||
|
||||
Reference in New Issue
Block a user