<div class="row m-3">
  <div class="col">
  </div>
  <div class="col">
    <%= search_form_for @q, url: internal_negative_reactions_path, class: "form-inline justify-content-end" do |f| %>

      <%= f.label :user_username_cont, "User", class: "sr-only" %>
      <%= f.search_field :user_username_cont, placeholder: "User", class: "form-control mx-3" %>

      <%= f.select(
            :category_eq,
            options_for_select(["", "vomit", "thumbsdown"], @q.category_eq),
            {},
            class: "custom-select mx-3",
          ) %>

      <%= f.submit "Search", class: "btn btn-secondary" %>
    <% end %>
  </div>
</div>

<%= paginate @negative_reactions %>

<table class="table">
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">User</th>
      <th scope="col">Type</th>
      <th scope="col">Action</th>
      <th scope="col">Content</th>
      <th scope="col">Date</th>
    </tr>
  </thead>
  <tbody>
    <% @negative_reactions.each do |reaction| %>
      <tr>
        <td><%= reaction.id %></td>
        <td><%= link_to reaction.user.username, internal_user_path(reaction.user_id) %></td>
        <td><%= reaction.reactable_type %></td>
        <td><%= reaction.category %></td>
        <td>
          <% if reaction.reactable_type == "Article" %>
            <%= link_to reaction.reactable.title, reaction.reactable.path %>
          <% elsif reaction.reactable_type == "User" %>
            <%= link_to reaction.reactable.username, reaction.reactable.path %>
          <% elsif reaction.reactable_type == "Comment" %>
            <%= link_to "#{reaction.reactable.user.username}'s Comment", reaction.reactable.path %>
          <% end %>
        </td>
        <td><%= reaction.created_at %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= paginate @negative_reactions %>
