<% provide :title, t("polls.index.title") %>

<%= render_custom_partial "meta_description" %>

<% content_for :canonical do %>
  <%= render "shared/canonical", href: polls_url %>
<% end %>

<%= render_custom_partial "social_meta_tags" %>

<%= render "shared/section_header", i18n_namespace: "polls.index.section_header", image: "polls" %>

<div class="row">
  <div class="small-12 column">
    <% if show_polls_description? %>
      <div class="polls-description">
        <%= auto_link_already_sanitized_html wysiwyg(@active_poll.description) %>
      </div>
    <% end %>

    <%= render "shared/filter_subnav", i18n_namespace: "polls.index" %>

    <% if @polls.any? %>
      <% polls_by_geozone_restriction = @polls.group_by(&:geozone_restricted) %>

      <% if polls_by_geozone_restriction[false].present? %>
        <h3 class="section-title-divider">
          <span><%= t("polls.index.no_geozone_restricted") %></span>
        </h3>
        <%= render "poll_group", poll_group: polls_by_geozone_restriction[false] %>
      <% end %>

      <% if polls_by_geozone_restriction[true].present? %>
        <h3 class="section-title-divider">
          <span><%= t("polls.index.geozone_restricted") %></span>
        </h3>
        <%= render "poll_group", poll_group: polls_by_geozone_restriction[true] %>
      <% end %>

      <%= paginate @polls %>
    <% else %>
      <div class="callout primary margin-top">
        <%= t("polls.index.no_polls") %>
      </div>
    <% end %>

    <div id="section_help" class="margin" data-magellan-target="section_help">
      <p class="lead">
        <strong><%= t("polls.index.section_footer.title") %></strong>
      </p>
      <p><%= t("polls.index.section_footer.description") %></p>
      <%= render_custom_partial "footer" %>
    </div>
  </div>
</div>
