<% has_archived = current_account.templates.where.not(archived_at: nil).exists? %> <% show_dropzone = params[:q].blank? && @pagy.pages == 1 && ((@template_folders.size < 10 && @templates.size.zero?) || (@template_folders.size < 7 && @templates.size < 4) || (@template_folders.size < 4 && @templates.size < 7)) %> <% if Docuseal.demo? %><%= render 'shared/demo_alert' %><% end %> <%= form_for '', url: '', id: form_id = SecureRandom.uuid, method: :post, class: 'hidden', data: { target: 'dashboard-dropzone.form' }, html: { enctype: 'multipart/form-data' } do %> <% end %>
<% unless show_dropzone %> <%= render 'templates/dashboard_dropzone', style: 'height: 114px' %> <% end %>
<% if has_archived || @pagy.count.nil? || @pagy.count > 0 || @template_folders.present? %>
<%= render 'dashboard/toggle_view', selected: 'templates' %>
<% end %>

<%= t('document_templates_html') %>

<% if params[:q].present? || @pagy.pages > 1 || @template_folders.present? %> <%= render 'shared/search_input' %> <% end %> <% if can?(:create, ::Template) %> <%= link_to new_template_path, class: 'white-button !border gap-2', data: { turbo_frame: :modal } do %> <%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %> <% end %> <% end %>
<% view_archived_html = capture do %> <% if has_archived %>
<%= t('view_archived') %>
<% end %> <% end %> <% templates_order_select_html = capture do %> <% if params[:q].blank? && @pagy.pages > 1 %> <%= render('shared/templates_order_select', with_recently_used: @pagy.count.present? && @pagy.count < 10_000) %> <% end %> <% end %> <% if @template_folders.present? %>
<%= render partial: 'template_folders/folder', collection: @template_folders, as: :folder %>
<% end %> <% if @templates.present? %>
<%= render partial: 'templates/template', collection: @templates %> <% if show_dropzone && (current_user.created_at > 2.weeks.ago || params[:tour] == 'true') && current_user == true_user %> <% user_config = current_user.user_configs.find_or_initialize_by(key: UserConfig::SHOW_APP_TOUR) %> <% if user_config.new_record? || user_config.value || params[:tour] == 'true' %> <% end %> <% end %>
<% end %>
<% if show_dropzone %> <%= render 'templates/dropzone' %> <% end %> <% if @templates.present? || @template_folders.present? || params[:q].blank? %> <% if @pagy.pages > 1 %> <%= render 'shared/pagination', pagy: @pagy, items_name: @templates.present? ? 'templates' : 'template_folders', left_additional_html: view_archived_html, right_additional_html: templates_order_select_html %> <% else %>
<%= view_archived_html %>
<% end %> <% elsif params[:q].present? %>
<%= t('templates_not_found') %>
<% end %> <%= render 'shared/review_form' %>