module Suppliers
  class OrdersController < Suppliers::ApplicationController
    # GET /tables
    # GET /tables.json
    def index
      if params[:state] == 'active'
        @orders = Order.active_for_supplier(current_supplier.id)
      else
        @orders  = Order.for_supplier(current_supplier, page: params[:page], per_page: params['per_page'] || 25)
      end

      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @orders }
      end
    end

    def show
      @order = current_supplier.find_order(params[:id])
      respond_to do |format|
        format.json { render json: @order }
      end
    end
  end
end
