<h1>Spammy Email Domains</h1>

<p>Additional checks on email addresses from these domains.</p>

<% if current_user.administrator? %>
  <p><%= link_to 'Add new', new_admin_spammy_email_domain_path %></p>
<% end %>

<table>
  <thead>
    <tr>
      <th>Domain</th>
      <th>Check</th>
      <th>Expires</th>
      <th>Block count</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @spammy_email_domains.each do |spammy_email_domain| %>
      <tr>
        <td><%= spammy_email_domain.domain %></td>
        <td><%= spammy_email_domain.description %></td>
        <td>
          <% if spammy_email_domain.expires_at %>
            <% if spammy_email_domain.expires_at.past? %>
              <span style="background-color: #FAA"><%= markup_date(spammy_email_domain.expires_at) %></span>
            <% else %>
              <%= markup_date(spammy_email_domain.expires_at) %>
            <% end %>
          <% end %>
        </td>
        <td style="text-align: right"><%= spammy_email_domain.block_count %></td>
        <td>
          <%= link_to('Edit', edit_admin_spammy_email_domain_path(spammy_email_domain)) if current_user.administrator? %>
          <%= link_to('Delete', admin_spammy_email_domain_path(spammy_email_domain), data: { turbo: true, turbo_method: :DELETE }) if current_user.administrator? %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
