<%= render 'shared/settings_nav' %>

Webhooks

<%= render 'shared/test_mode_toggle' %>
<%= form_for @webhook_url, url: settings_webhooks_path, method: :post, html: { autocomplete: 'off' } do |f| %> <%= f.label :url, 'Webhook URL', class: 'text-sm font-semibold' %>
<%= f.url_field :url, class: 'input font-mono input-bordered w-full', placeholder: 'https://example.com/hook' %> <%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button w-full md:w-32' %> <% if @webhook_url.persisted? %> <%= @webhook_url.secret.present? ? t('edit_secret') : t('add_secret') %> <% end %>
<% WebhookUrl::EVENTS.group_by { |e| e.include?('form') }.each do |_, events| %>
<%= f.collection_check_boxes(:events, events, :to_s, :to_s, include_hidden: false) do |b| %>
<% end %>
<% end %> <% end %>
<% submitter = current_account.submitters.where.not(completed_at: nil).order(:id).last %> <% if submitter %>
<%= t('submission_example_payload') %> <% if @webhook_url.url.present? && @webhook_url.events.include?('form.completed') %> <%= button_to button_title(title: 'Test Webhook', disabled_with: t('sending'), icon_disabled: svg_icon('loader', class: 'w-4 h-4 animate-spin')), settings_webhooks_path, class: 'btn btn-neutral btn-outline btn-sm', method: :put %> <% end %>
<%= render 'shared/clipboard_copy', icon: 'copy', text: code = JSON.pretty_generate({ event_type: 'form.completed', timestamp: Time.current.iso8601, data: Submitters::SerializeForWebhook.call(submitter) }).gsub(/^/, ' ').sub(/^\s+/, ''), class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: t('copy'), copied_title: t('copied') %>
<%= code %>
<% end %>