module CmAdmin::ViewHelpers::FormFieldHelper

def attachment_with_icon(cm_field, attachment, attachment_name:)

def attachment_with_icon(cm_field, attachment, attachment_name:)
  content_tag(:div, data: { section: 'destroy-attachment', ar_id: attachment.id, attachment_name: }) do
    concat(content_tag(:a, href: attachment.url, target: '_blank') do
      if attachment.content_type.include?('image')
        image_tag(attachment.url, height: 50, width: 50, class: "rounded")
      end
    end) if cm_field.image_preview
    concat content_tag(:span, attachment.filename.to_s, class: 'btn-link')
    concat(content_tag(:button, '', class: 'btn-ghost') do
      concat tag.i(class: 'fa-regular fa-trash-can')
    end) if cm_field.input_type == :single_file_upload
  end
end