ActiveAdmin.register JamRuby::TeacherPayment, :as => 'TeacherPayments' do

  menu :label => 'Teacher Payments', :parent => 'JamClass'

  config.sort_order = 'created_at desc'
  config.batch_actions = false
  config.per_page = 100
  config.paginate = true
  config.filters = true

  controller do
    active_admin_config.includes.push :teacher
  end

  filter :teacher_full_name_or_teacher_email_cont, label: 'Name', as: :string

  index do
    column "Actions" do |payment|
      links = ''.html_safe
      links << link_to("View", resource_path(payment), :class => "member_link view_link")
      links << link_to("Edit", edit_resource_path(payment), :class => "member_link edit_link")
      links
    end
    column "Teacher" do |payment|
      link_to payment.teacher.name, payment.teacher.admin_url
    end
    column :amount_in_cents
    column :fee_in_cents
    column :created_at
    column :updated_at
  end

  show do
    attributes_table do
      row "Teacher" do |payment|
        link_to payment.teacher.name, payment.teacher.admin_url
      end
      row :amount_in_cents
      row :fee_in_cents
      row :created_at
      row :updated_at
    end
  end

end