Mostly enriching supplier's user info with number of lists finished at the restaurant

This commit is contained in:
2020-03-06 19:27:44 -05:00
parent f1ef618dae
commit eda3fc280b
7 changed files with 66 additions and 8 deletions
@@ -19,7 +19,8 @@ module Suppliers
else
@lists = List.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25)
end
@lists.include_relation(:table, :users, orders: {user: nil, product_orders: :product})
@lists.include_relations(:table, :users, orders: {user: nil, product_orders: :product})
List.enrich_users_number_of_lists_at_supplier current_supplier.id, @lists
render json: @lists, include: %w[
orders
@@ -31,8 +31,10 @@ module Suppliers
def switch_to
@switch_supplier = Supplier.find(params[:id])
session[:supplier_id] = params[:id] if @switch_supplier.employee_ids.include? current_employee.id
redirect_to supplier_root_path(other: '/my-account')
#TODO sessions currently not working, just tokens
session[:supplier_id] = @switch_supplier.id if @switch_supplier.employee_ids.include? current_employee.id
render json: {ok: true}
#redirect_to supplier_root_path(other: '/my-account')
end
def mark_as_open