ActiveAdmin.register  JamRuby::RecurlyTransactionWebHook, :as => 'RecurlyHooks' do

  menu :label => 'Recurly Transaction Hooks', :parent => 'Purchases'

  config.sort_order = 'created_at DESC'
  config.batch_actions = false

  actions :all, :except => [:destroy]

  #form :partial => 'form'


  filter :transaction_type, :as => :select,      :collection => JamRuby::RecurlyTransactionWebHook::HOOK_TYPES
  filter :user_id,
         :label => "USER ID", :required => false,
         :wrapper_html => { :style => "list-style: none" }

  filter :invoice_id

  form :partial => 'form'

  index do

    actions

    column :transaction_type
    column :transaction_at
    column :amount_in_cents
    column 'Transaction' do |hook| link_to('Go to Recurly', Rails.application.config.recurly_root_url + "/transactions/#{hook.recurly_transaction_id}") end
    column 'Invoice' do |hook| link_to(hook.invoice_number, Rails.application.config.recurly_root_url + "/invoices/#{hook.invoice_number}") end
    column :admin_description
    column 'User' do |hook| link_to("#{hook.user.email} (#{hook.user.name})", admin_user_path(hook.user.id)) end

    #column "Order" do |right|
      #link_to("Place", order_admin_jam_track_right_path(right)) + " | " +
    #  link_to("Refund", refund_admin_jam_track_right_path(right))
    #end
  end

end