ActiveAdmin.register JamRuby::User, :as => 'UserSource' do

  menu :label => 'User Campaigns', :parent => 'Users'

  config.sort_order = 'created_at DESC'
  config.batch_actions = false
  config.clear_action_items!
  config.filters = false

  scope("Most Recent First", default: true) { |scope| scope.unscoped.order('created_at desc')}

  index do
    column "Email" do |user|
      user.email
    end
    column "Bought TestDrive" do |user|
      !user.most_recent_test_drive_purchase.nil? ? "Yes" : "No"
    end
    column "UTM Source" do |user|
      user.origin_utm_source
    end
    column "UTM Medium" do |user|
      user.origin_utm_medium
    end
    column "UTM Campaign" do |user|
      user.origin_utm_campaign
    end
    column "Referrer" do |user|
      user.origin_referrer
    end
  end
end
