class Cooperative::UsersController < Cooperative::BaseController
  def index
    default_sort('created_on', 'desc')

    users = Admins::UserQuery.call(search_params.merge(laboratory_id: current_laboratory.id))
    @users = paginate users.includes(user_extension: :school)
  end

  def for_select
    default_sort('created_on', 'desc')

    users = Admins::UserQuery.call(search_params)
    @users = paginate users.includes(user_extension: :school)
  end

  private

  def search_params
    params.permit(:identity, :name, :keyword, :school_name, :sort_by, :sort_direction)
  end
end