class Admins::UserActionsController < Admins::BaseController
  before_action :require_admin

  def index
    @user_actions = UserAction.order(created_at: :desc)
    @user_actions = @user_actions.where(action_type: params[:action_type]) if params[:action_type].present?
    keyword = params[:keyword].to_s.strip.presence
    if keyword
      sql = 'login LIKE :keyword OR phone LIKE :keyword OR email LIKE :keyword'
      @user_actions = @user_actions.where(sql, keyword: "%#{keyword}%")
    end
    @user_actions = paginate @user_actions
  end
end
