<% content_for :title, "Create a notification" %>

<div class="govuk-grid-row">
  <div class="govuk-grid-column-three-quarters-from-desktop">
    <% content_for :before_content do %>
      <%= govuk_back_link(href: :back) %>
    <% end %>

    <h1 class="govuk-heading-l">
      <span class="govuk-caption-l">Create a notification</span>
      Check your answers
    </h1>

    <span class="govuk-caption-m govuk-!-margin-bottom-6">This notification will be visible to all users until you delete it</span>

    <%= form_for(@notification, method: :patch) do |f| %>
      <%= f.govuk_error_summary %>

      <div class="govuk-summary-card">
        <div class="govuk-summary-card__content">
          <%= govuk_summary_list do |summary_list| %>
            <% summary_list.with_row do |row| %>
              <% row.with_key { "Title" } %>
              <% row.with_value do %>
                <%== render_for_summary(@notification.title) %>
              <% end %>
              <% row.with_action(text: "Change", href: edit_notification_path(@notification)) %>
            <% end %>
            <% summary_list.with_row do |row| %>
              <% row.with_key { "Show on unauthenticated pages?" } %>
              <% row.with_value { @notification.show_on_unauthenticated_pages ? "Yes" : "No" } %>
              <% row.with_action(text: "Change", href: edit_notification_path(@notification)) %>
            <% end %>
            <% summary_list.with_row do |row| %>
              <% row.with_key { "Link to additional information?" } %>
              <% row.with_value { @notification.show_additional_page ? "Yes" : "No" } %>
              <% row.with_action(text: "Change", href: edit_notification_path(@notification)) %>
            <% end %>
            <% if @notification.show_additional_page %>
              <% summary_list.with_row do |row| %>
                <% row.with_key { "Link text" } %>
                <% row.with_value { @notification.link_text } %>
                <% row.with_action(text: "Change", href: edit_notification_path(@notification)) %>
              <% end %>
              <% summary_list.with_row do |row| %>
                <% row.with_key { "Page content" } %>
                <% row.with_value do %>
                  <%= govuk_link_to "View page preview", notification_path(@notification), new_tab: true %>
                <% end %>
                <% row.with_action(text: "Change", href: edit_notification_path(@notification)) %>
              <% end %>
            <% end %>
          <% end %>
        </div>
      </div>

      <%= f.hidden_field :start_now, value: true %>
      <%= f.govuk_submit "Create notification" %>
    <% end %>
  </div>
</div>