<% if file.present? %>
<% if file.representable? && is_image? %>
<%= image_tag helpers.main_app.url_for(file), class: 'rounded-lg object-cover' %>
<% elsif is_audio? %> <%= audio_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %> <% elsif is_video? %> <%= video_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %> <% else %>
<%= helpers.svg 'document-text', class: 'h-10 text-gray-600 mb-2' %>
<% end %> <%= file.filename %>
<% if @resource.authorization.authorize_action(:download_attachments?, raise_exception: false) %> <%= a_link file.url(disposition: :attachment), icon: 'heroicons/outline/download', color: :primary, download: true, class: 'text-center', title: t('avo.download_file'), data: { tippy: :tooltip }, compact: true, size: :xs %> <% end %>
<% if @resource.authorization.authorize_action(:delete_attachments?, raise_exception: false) %> <%= a_link destroy_path, icon: 'heroicons/outline/trash', method: :delete, color: :red, compact: true, size: :xs, class: 'text-center', title: t('avo.delete_file', item: file.filename), data: { 'turbo-frame': 'destroy_attachment_form', confirm: t('avo.are_you_sure'), tippy: :tooltip } %> <% end %>
<% else %> – <% end %>