json.(@tutoring_sessions) do |tutoring_session|
  json.id tutoring_session.id
  json.path tutoring_session_path(tutoring_session)
  json.status_label tutoring_session.status_label
  json.start tutoring_session.start_time
  json.end tutoring_session.end_time
  json.group_id tutoring_session.resource.group.id
  if tutoring_session.tutor == current_user
    json.label tutoring_session.user.name
    if tutoring_session.pending?
      json.link link_to 'Respond', respond_tutor_tutoring_session_path(tutoring_session), class: 'txt-white fs8 semibold', data: {toggle: :modal, target: '#remote-modal'}
    end
  elsif
    json.label tutoring_session.tutor.name
    if tutoring_session.passed_but_not_paid?
      json.link link_to 'Rate and Pay', rating_tutoring_session_path(tutoring_session), class: 'txt-white pl10 fs8 semibold', data: {toggle: :modal, target: '#remote-modal'}
    end
  end
end

if @availabilities
  json.(@availabilities) do |availability|
    json.start availability[:start]
    json.end availability[:end]
    json.status_label 'available'
  end
end

if @schedule_events
  json.(@schedule_events) do |event|
    json.label event.name
    json.path event_path(event)
    json.start event.start_time
    json.end event.end_time
    if event.grouped?
      json.status_label 'my-group-event'
    else
      json.status_label 'my-event'
    end
    if event.can_delete?(current_user)
      json.edit_link link_to content_tag(:span, nil, class: 'fa fa-pencil'), edit_event_path(event), class: 'edit-link', data: {toggle: :modal, target: '#remote-modal'}
      if event.grouped?
        json.group_name event.shares.last.try(:shared_to).try(:name)
        json.label event.name
        json.group_id event.shares.last.try(:shared_to_id)
      end
    end
  end
end

if @other_user_tutoring_sessions
  json.(@other_user_tutoring_sessions) do |tutoring_session|
    json.id tutoring_session.id
    json.label 'Busy'
    json.status_label 'busy-event'
    json.start tutoring_session.start_time
    json.end tutoring_session.end_time
    json.user_id @other_user.id
  end
end


if @other_user_availabilities
  json.(@other_user_availabilities) do |availability|
    json.start availability[:start]
    json.end availability[:end]
    json.status_label 'available'
    json.user_id availability[:user_id]
  end
end


unless @other_user_class_schedules.blank?
  json.(@other_user_class_schedules) do |schedule|
    json.group_id schedule.group.id
    json.label 'Busy'
    json.status_label 'busy-event'
    json.start schedule.start_time(@start_date)
    json.end schedule.end_time(@start_date)
    json.user_id @other_user.id
  end
end

if @other_user_schedule_events
  json.(@other_user_schedule_events) do |event|
    json.label 'Busy'
    json.start event.start_time
    json.end event.end_time
    json.status_label 'busy-event'
    json.user_id @other_user.id
    if event.grouped?
      json.group_id event.shares.last.shared_to_id
    end
  end
end
