<%= render 'shared/turbo_modal_large', title: 'Preferences', close_after_submit: false do %> <% options = [['General', 'general'], ['API and Embedding', 'api']] %>
<% options.each_with_index do |(label, value), index| %> <%= radio_button_tag 'option', value, value == 'general', class: 'peer hidden', data: { action: 'change:toggle-visible#trigger' } %> <% end %>
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' } do |f| %> <%= f.fields_for :preferences, Struct.new(:request_email_subject, :request_email_body).new(*(@template.preferences.values_at('request_email_subject', 'request_email_body').compact_blank.presence || AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY).value.values_at('subject', 'body'))) do |ff| %>
<%= ff.label :request_email_subject, 'Email subject', class: 'label' %> <%= ff.text_field :request_email_subject, required: true, class: 'base-input', dir: 'auto' %>
<%= ff.label :request_email_body, 'Email body', class: 'label' %> <%= svg_icon('info_circle', class: 'w-4 h-4') %>
<%= ff.text_area :request_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
<% end %>
<%= f.button button_title(title: 'Save', disabled_with: 'Saving'), class: 'base-button' %>
<% end %> <%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' } do |f| %> <%= f.fields_for :preferences, Struct.new(:bcc_completed).new(@template.preferences['bcc_completed']) do |ff| %>
<%= ff.label :bcc_completed, class: 'label' do %> Completed documents BCC address <% end %> <%= tag.input type: 'email', multiple: true, name: 'template[preferences][bcc_completed]', autocomplete: 'off', class: 'base-input', value: ff.object.bcc_completed %>
<% end %>
<%= f.button button_title(title: 'Save', disabled_with: 'Updating'), class: 'base-button' %>
<% end %> <%= render 'templates_code_modal/preferences' %>
<% end %>