<%# ## TODO: if first comment or activity on record add table? %>
if ($(".all-activities-tab").find("table > tbody > tr").length === 3) {
  $(".all-activities-tab").find("table > tbody > tr:last").remove();
}

$(".all-activities-tab").find(".activities-history--table").prepend("<%= j render @activity, locals: { link: false } %>");
$('.all-activities-tab .default-message').remove();

if ("<%= @activity.kind %>" === "note") {
  if ($(".activity-tab-for-notes").find("table > tbody > tr").length === 3) {
    $(".activity-tab-for-notes").find("table > tbody > tr:last").remove();
  }

  $(".activity-tab-for-notes").find(".activities-history--table").prepend("<%= j render @activity, locals: { link: false } %>");
  $('.activity-tab-for-notes .default-message').remove();
}

if ("<%= @activity.kind %>" === "outcome") {
  if ($(".activity-tab-for-outcomes").find("table > tbody > tr").length === 3) {
    $(".activity-tab-for-outcomes").find("table > tbody > tr:last").remove();
  }

  $(".activity-tab-for-outcomes").find(".activities-history--table").prepend("<%= j render @activity, locals: { link: false } %>");
  $('.activity-tab-for-outcomes .default-message').remove();
}

if ("<%= @activity.kind %>" === "call") {
  $(".activity-tab-for-calls .activity-stream").prepend("<%= j render @activity, locals: { link: false } %>");
  $('.activity-tab-for-calls .default-message').remove();
}

if ("<%= @activity.kind %>" === "meeting") {
  $(".activity-tab-for-meetings .activity-stream").prepend("<%= j render @activity, locals: { link: false } %>");
  $('.activity-tab-for-meetings .default-message').remove();
}

toastr.success('Activity was successfully created.');
$('.all-activities-tab').find('.activity-comment-form--input').val('');
$('.activity-tab-for-notes').find('.activity-comment-form--input').val('');
