<% title "Dashboard - DEV" %>

<div class="dashboard-container" id="user-dashboard">
  <%= render "actions" %>
  <h2>Followed tags (<%= @user.following_tags_count %>)</h2>
  <p><em>Adjust <strong>Follow Weight</strong> to make a tag show up less or more in your feed (default 1.0)</em>
  </p>
  <% negative_follow_shown_once = false %>
  <% @followed_tags.each do |follow| %>
    <% tag = follow.followable %>
    <% if tag %>
      <% if follow.points < 0 && !negative_follow_shown_once %>
        <h2>Negative Tags (anti-follows)</h2>
        <% negative_follow_shown_once = true %>
      <% end %>
      <% color = HexComparer.new([tag.bg_color_hex || "#0000000", tag.text_color_hex || "#ffffff"]).brightness(0.8) %>
      <div class="single-article" style="border-color:<%= color %>;box-shadow: 3px 3px 0px <%= color %>">
        <h2>
          <a href="/t/<%= tag.name %>">
            <%= tag.name %>
          </a>
          <%= form_for(follow) do |f| %>
            <%= f.label(:points, "Follow Weight:") %>
            <%= f.number_field(:points, step: :any, required: true) %>
            <%= f.submit "Submit" %>
          <% end %>
        </h2>
      </div>
    <% end %>
  <% end %>

  <h2>Followed users (<%= @user.following_users_count %>)</h2>
  <% @follows.each do |follow| %>
    <% user = follow.followable %>
    <% if user %>
      <div class="single-article">
        <a href="<%= user.path %>" class="block-link">
          <h2>
            <img alt="<%= user.username %> profile image" src="<%= ProfileImage.new(user).get(60) %>" />
            <%= user.name %>
            <span class="dashboard-username">@<%= user.username %></span>
          </h2>
        </a>
      </div>
    <% end %>
  <% end %>

  <h2>Followed organizations (<%= @user.following_organizations_count %>)</h2>
  <% @followed_organizations.each do |follow| %>
    <% organization = follow.followable %>
    <div class="single-article">
      <a href="<%= organization.path %>" class="block-link">
        <h2>
          <img alt="<%= organization.name %> profile image" src="<%= ProfileImage.new(organization).get(60) %>" />
          <%= organization.name %>
          <span class="dashboard-username">@<%= organization.name %></span>
        </h2>
      </a>
    </div>
  <% end %>

  <h2>Followed podcasts (<%= @user.following_podcasts_count %>)</h2>
  <% @followed_podcasts.each do |follow| %>
    <% podcast = follow.followable %>
    <% if podcast %>
      <div class="single-article">
        <a href="/<%= podcast.path %>" class="block-link">
          <h2>
            <img alt="<%= podcast.name %> profile image" src="<%= podcast.image_url %>" />
            <%= podcast.name %>
            <span class="dashboard-username">@<%= podcast.name %></span>
          </h2>
        </a>
      </div>
    <% end %>
  <% end %>
</div>
