<% if @email_messages.blank? %>
  <div class="alert alert-info alert-dismissible">
    <h5><i class="icon fas fa-info"></i> Informacja</h5>
      Brak elementów na liście
  </div>
<% else %>

<table class="table table-bordered">
  <thead>
    <tr>
      <th>E-mail</th>
      <th>Temat</th>
      <th>Wiadomość</th>
      <th>Utworzono</th>
      <th style="width: 200px">Akcje</th>
    </tr>
  </thead>

  <tbody>
    <% @email_messages.each do |email_message| %>
      <tr>
        <td><%= email_message.email %></td>
        <td><%= email_message.subject %></td>
        <td><%= email_message.message %></td>
        <td><%= email_message.created_at.strftime("%Y-%m-%d %H:%M:%S") unless email_message.created_at.blank? %></td>
        <td>
          <%= link_to raw('<i class="fas fa-trash-can"></i> Usuń'), "/settings/email_messages/#{email_message.id}", class: 'btn-sm btn-danger', method: :delete, data: { confirm: 'Czy na pewno?' } %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<% end %>
