module Admin::TutorsHelper

  # Provides checkbox to make tutor searchable/unsearchable
  def admin_tutor_searchable_link(tutor)
    if tutor.active? && tutor.is_registration_completed?
      if tutor.searchable?
        link_to unmark_searchable_admin_tutor_path(tutor), method: :patch, remote: true, data: {confirm: "Do you want to revoke user - \"#{tutor.full_name}\" from search?"} do
          check_box_tag 'unsearchable', true, true
        end
      else
        link_to mark_searchable_admin_tutor_path(tutor), method: :patch, remote: true, data: {confirm: "Do you want to add user - \"#{tutor.name}\" in search?"} do
          check_box_tag 'searchable', true, false
        end
      end
    else
      '-'
    end
  end

  # Provides link to resend activation link to tutor if it was not activated or for Intimate Profile Completion.
  def admin_tutor_status_link(tutor)
    if tutor.is_registration_completed?
      'Yes'
    else
      link = unless tutor.active?
        link_to 'Resend Activation!', resend_activation_admin_user_path(tutor), remote: true
      else
        link_to 'Intimate Profile Completion', intimate_profile_completion_admin_tutor_path(tutor), remote: true
      end
      ('No - ' + link).html_safe
    end
  end

  # Provides checkbox to make tutor featured/unfeatured
  def admin_tutor_featured_link(tutor)
    if tutor.active? && tutor.is_registration_completed?
      if tutor.is_featured?
        link_to unmark_featured_admin_tutor_path(tutor), method: :patch, remote: true, data: {confirm: "Do you want to revoke user - \"#{tutor.full_name}\" from featured?"} do
          check_box_tag 'unfeatured', true, true
        end
      else
        link_to mark_featured_admin_tutor_path(tutor), method: :patch, remote: true, data: {confirm: "Do you want to add user - \"#{tutor.name}\" in featured?"} do
          check_box_tag 'featured', true, false
        end
      end
    else
      '-'
    end
  end

end
