<%= render 'shared/turbo_modal', title: t('webhook_security') do %>
  <div class="text-center mb-4">
    <div class="inline-flex justify-center">
      <%= link_to t('secret'), webhook_secret_path(@webhook_url), class: 'block bg-base-300 md:min-w-[112px] text-sm font-semibold whitespace-nowrap py-1.5 px-4 rounded-l-3xl', data: { turbo_frame: 'modal' } %>
      <%= link_to t('hmac'), webhook_hmac_path(@webhook_url), class: 'block bg-base-200 md:min-w-[112px] text-sm font-semibold whitespace-nowrap py-1.5 px-4 rounded-r-3xl', data: { turbo_frame: 'modal' } %>
    </div>
  </div>
  <%= form_for @webhook_url, url: webhook_secret_path, method: :patch, html: { class: 'space-y-4' }, data: { turbo_frame: :_top } do |f| %>
    <div class="space-y-2">
      <%= f.fields_for :secret, Struct.new(:key, :value).new(*@webhook_url.secret.to_a.first) do |ff| %>
        <div class="form-control">
          <%= ff.label :key, t('key'), class: 'label' %>
          <%= ff.text_field :key, class: 'base-input', placeholder: 'X-Example-Header' %>
        </div>
        <div class="form-control">
          <%= ff.label :value, t('value'), class: 'label' %>
          <%= ff.text_field :value, class: 'base-input' %>
        </div>
      <% end %>
    </div>
    <div class="form-control pt-2">
      <%= f.button button_title, class: 'base-button' %>
    </div>
  <% end %>
<% end %>
