<% if notification.action == "Reaction" %>
  <%= render "reaction", notification: notification %>
<% elsif notification.action.include? "Milestone" %>
  <%= render "milestone", notification: notification %>
<% else %>
  <% json_data = notification.json_data %>
  <% if json_data["organization"] %>
    <div class="article-organization-headline">
      <a class="org-headline-filler" href="<%= json_data["organization"]["path"] %>">
        <img alt="<%= json_data["organization"]["name"] %> logo" src="<%= json_data["organization"]["profile_image_90"] %>">
        <%= json_data["organization"]["name"] %>
      </a>
   </div>
  <% end %>
  <a href="<%= json_data["user"]["path"] %>" class="small-pic-link-wrapper">
    <div class="small-pic">
      <img src="<%= json_data["user"]["profile_image_90"] %>" alt="link to <%= json_data["user"]["username"] %>'s profile">
    </div>
  </a>
  <div class="content notification-content article-content">
    <a href="<%= json_data["user"]["path"] %>">
      <%= json_data["user"]["name"] %>
    </a>
    made a new post<%= ":" unless json_data["organization"] %>
    <% if json_data["organization"] %>
      under <a href="<%= json_data["organization"]["path"] %>"><%= json_data["organization"]["name"] %></a>:
    <% end %>

    <div>
      <small><%= time_ago_in_words json_data["article"]["published_at"] %> ago</small>
    </div>

    <a href="<%= json_data["article"]["path"] %>">
      <div class="notification-new-post">
        <div class="notification-new-post-title">
          <%= h(json_data["article"]["title"]) %>
        </div>
        <div class="notification-new-post-tags">
          <% json_data["article"]["cached_tag_list_array"].each do |tag| %>
            #<%= tag %>
          <% end %>
        </div>
      </div>
    </a>

    <% cache "activity-published-article-reactions-#{@last_user_reaction}-#{json_data['article']['updated_at']}-#{json_data['article']['id']}" do %>
      <div class="comment-actions">
        <button class="reaction-button <%= Reaction.cached_any_reactions_for?(notification.mocked_object("article"), current_user, "like") ? "reacted" : "" %>" data-reactable-id="<%= json_data["article"]["id"] %>" data-category="like" data-reactable-type="Article">
          <%= image_tag("favorite-heart-outline-button.svg", alt: "Favorite heart outline button") %>
          <img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-heart.png") %>" alt="Favorite heart button" />
        </button>
        <button class="reaction-button readinglist-button <%= Reaction.cached_any_reactions_for?(notification.mocked_object("article"), current_user, "readinglist") ? "reacted" : "" %>" data-reactable-id="<%= json_data["article"]["id"] %>" data-category="readinglist" data-reactable-type="Article">
          <span class="reaction-button-text">SAVE</span>
          <img class="reacted-emoji reaction-button-reacted-emoji" src="<%= asset_path("readinglist-button.png") %>" alt="Reading list button" />
        </button>
      </div>
    <% end %>
  </div>
<% end %>
