  json.name group.name
  json.id group.id
  json.type group.class.name
  json.task_url tasks_path(group_id: group.id)

  if group.class.name == 'Group'
    if group.user_group?
      json.user_group true
      if group.resource_id == current_user.id
        json.edit_url edit_group_path(group.id)
        json.delete_url group_path(group.id)
      end
    end
  end
  if current_user
    json.tutors do
      @group_tutors = group.tutors.searchable.filter(params[:query]).except_user(current_user).page(1).per(3)
      json.(@group_tutors) do |t|
        json.id t.id
        json.name t.full_name
        json.exp_title t.exp_title
        json.image image_path(t.image_url(:thumb))
        json.type 'Tutor'
        if t.available_for_video?
          if group.class.name == 'Group' && group.tutorable?
            json.video_session_url new_video_session_path(session: {resource_type: group.resource_type, resource_id: group.resource_id, tutor_id: t.id})
          else
            json.video_session_url new_video_session_path(session: {tutor_id: t.id})
          end
        end
        #if current_user.is_favorite_users?(t)
        #  json.unfriend_url unmark_user_favorites_path(t.id)
        #else
        #  json.friend_url mark_user_favorites_path(t.id)
        #end
        json.profile_calendar_url profile_path(id: t.id, tab: 'appointments')
        json.invoice_url profile_path(id: t.id, tab: 'pay')
      end
    end
  else
    json.tutors do
      @group_tutors = group.tutors.searchable.filter(params[:query]).page(1).per(3)
      json.(@group_tutors) do |t|
        json.id t.id
        json.name t.full_name
        json.exp_title t.exp_title
        json.image image_path(t.image_url(:thumb))
        json.type 'tutor'
      end
    end
  end

  if @group_tutors.present?
    json.set! :show_more_tutors_url, (link_to_next_page @group_tutors, 'Show More', params: {group_id: group.id, user_type: 'tutor', type: group.class.name}, remote: true).try(:html_safe)
  end

  if @group_students.present?
    json.set! :show_more_students_url, (link_to_next_page @group_students, 'Show More', params: {group_id: group.id, user_type: 'student', type: group.class.name},remote: true).try(:html_safe)
  end
