<%= render 'shared/logo', width: 40, height: 40 %> <%= @submission.template.name %>
<% if last_submitter = @submission.submitters.to_a.select(&:completed_at?).max_by(&:completed_at) %> <%= svg_icon('download', class: 'w-6 h-6') %> Download <% elsif @submission.submitters.to_a.size == 1 %> <%= render 'shared/clipboard_copy', text: start_form_url(slug: @submission.template.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy Share Link', copied_title: 'Copied to Clipboard' %> <% end %>
<% fields_index = Templates.build_field_areas_index(@submission.template) %> <% values = @submission.submitters.reduce({}) { |acc, sub| acc.merge(sub.values) } %> <% attachments_index = ActiveStorage::Attachment.where(record: @submission.submitters, name: :attachments).preload(:blob).index_by(&:uuid) %> <% @submission.template.schema.each do |item| %> <% document = @submission.template.documents.find { |e| e.uuid == item['attachment_uuid'] } %> <% document.preview_images.sort_by { |a| a.filename.base.to_i }.each_with_index do |page, index| %>
" class="relative">
<% fields_index.dig(document.uuid, index)&.each do |(area, field)| %> <% value = values[field['uuid']] %> <% next if value.blank? %> <%= render 'submissions/value', area:, field:, attachments_index:, value:, locale: current_account.locale %> <% end %>
<% end %> <% end %>