<div class="mb-8">
  <h3 id="api-key"><%= t("users.registrations.edit.api_key.title") %></h3>
  <p>
    <%= t("users.registrations.edit.api_key.description") %>
  </p>
  <% if current_user.api_key %>
    <div class="api-key-display">
      <p>
        <% if flash[:token] %>
          <%= flash[:token] %>
        <% else %>
          <%= '*' * (current_user.api_key.length - 4) + current_user.api_key.last(4) %>
        <% end %>
      </p>
      <% if current_user.api_key_expires_at < Time.current %>
        <p class="">
          <%= t("users.registrations.edit.api_key.expired") %>
        </p>
      <% end %>
    </div>
  <% end %>
  <div class="flex">
    <% if current_user.api_key %>
      <%= button_to t("users.registrations.edit.api_key.regenerate"), users_api_key_regenerate_path, class: "btn btn-primary mr-2" %>
      <%= button_to t("users.registrations.edit.api_key.revoke"), users_api_key_revoke_path, class: "btn btn-danger" %>
    <% else %>
      <%= button_to t("users.registrations.edit.api_key.generate"), users_api_key_regenerate_path, class: "btn btn-primary" %>
    <% end %>
  </div>
</div>
