<% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %>
<% with_filters = @pagy.pages > 1 || params[:q].present? || filter_params.present? %>
<%= render 'templates/title', template: @template %>
<div class="flex flex-col md:flex-row md:items-center mb-6 gap-3">
  <div class="flex w-full justify-between md:items-end items-end">
    <div>
      <div>
        <%= link_to template_path(@template), class: 'flex items-center' do %>
          <%= svg_icon('chevron_left', class: 'w-5 h-5') %>
          <span style="margin-left: 3px"><%= t('back_to_active') %></span>
        <% end %>
      </div>
      <h1 class="text-3xl font-bold md:block"><%= t('submissions') %> <span class="badge badge-outline badge-lg align-middle"><%= t('archived') %></span></h1>
    </div>
    <div class="flex space-x-2 justify-end">
      <% if with_filters %>
        <%= render 'shared/search_input' %>
      <% end %>
      <%= link_to new_template_submissions_export_path(@template, archived: true), class: 'btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
        <%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
        <span><%= t('export') %></span>
      <% end %>
    </div>
  </div>
  <% if with_filters %>
    <div class="flex flex-col items-end md:flex-row gap-2">
      <%= render 'submissions_filters/applied_filters', filter_params: %>
      <%= render 'submissions_filters/filter_button', filter_params: %>
    </div>
  <% end %>
</div>
<% if @pagy.count.nil? || @pagy.count > 0 %>
  <div class="space-y-4">
    <%= render partial: 'templates/submission', collection: @submissions, locals: { template: @template, archived: true } %>
  </div>
<% elsif params[:q].present? || filter_params.present? %>
  <div class="text-center">
    <div class="mt-16 text-3xl font-semibold">
      <%= t('submissions_not_found') %>
    </div>
  </div>
<% end %>
<%= render 'shared/pagination', pagy: @pagy, items_name: 'submissions' %>
