<%= back_link_to %>

<h2><%= t("admin.newsletters.show.title") %></h2>

<% recipients_count = @newsletter.valid_segment_recipient? ? @newsletter.list_of_recipient_emails.count : 0 %>

  <div class="small-12 column callout highlight">
    <div class="small-12 medium-2 column">
      <strong><%= t("admin.newsletters.show.sent_at") %></strong><br>
      <% if @newsletter.draft? %>
        <%= t("admin.newsletters.index.draft") %>
      <% else %>
        <%= l @newsletter.sent_at.to_date %>
      <% end %>
    </div>
    <div class="small-12 medium-6 column">
      <strong><%= t("admin.newsletters.show.from") %></strong><br>
      <%= @newsletter.from %>
    </div>
    <div class="small-12 medium-4 column">
      <strong><%= t("admin.newsletters.show.subject") %></strong><br>
      <%= @newsletter.subject %>
    </div>
    <div class="small-12 column">
      <strong><%= t("admin.newsletters.show.segment_recipient") %></strong><br>
      <%= segment_name(@newsletter.segment_recipient) %>
      <%= t("admin.newsletters.show.affected_users", n: recipients_count) %>
    </div>

    <div class="small-12 column">
      <strong>
        <%= t("admin.newsletters.show.sent_emails", count: @newsletter.activities.count) %>
      </strong>
    </div>
  </div>

  <div class="small-12 column">
    <strong><%= t("admin.newsletters.show.body") %></strong>
    <p class="help-text" id="phase-description-help-text">
      <%= t("admin.newsletters.show.body_help_text") %>
    </p>
  </div>

  <div class="newsletter-body-content">
    <%= render file: "app/views/layouts/_mailer_header.html.erb" %>

    <table cellpadding="0" cellspacing="0" border="0" style="background: #fff; margin: 0 auto; max-width: 700px; width:100%;">
      <tbody>
        <tr>
          <%= render file: "app/views/mailer/newsletter.html.erb" %>
        </tr>
      </tbody>
    </table>

    <%= render file: "app/views/layouts/_mailer_footer.html.erb" %>
  </div>
</div>

<% if @newsletter.draft? && @newsletter.valid_segment_recipient? %>
  <%= link_to t("admin.newsletters.show.send"),
              deliver_admin_newsletter_path(@newsletter),
              "data-alert": t("admin.newsletters.show.send_alert", n: recipients_count),
              method: :post,
              id: "js-send-newsletter-alert",
              class: "button success" %>
<% end %>
