{% import "macros/datatable.html" as datatable %}

{% macro url_column(webhook) %}
<a
  class="font-medium text-slate-800 hover:text-slate-900"
  href="{{ url_for('dashboard.webhooks:get', id=webhook.id) }}"
  hx-boost="true"
  hx-target="#aside"
  _="install OpenAside"
>
  {{ webhook.url }}
</a>
{% endmacro %}

{% macro created_at_column(webhook) %}
{{ webhook.created_at.strftime('%x %X') }}
{% endmacro %}

{% macro events_column(webhook) %}
{{ webhook.events | join(', ') }}
{% endmacro %}

{% macro actions_column(webhook) %}
<div class="flex justify-end">
  <a
    class="btn-xs border-slate-200 hover:border-slate-300"
    href="{{ url_for('dashboard.webhooks:logs', id=webhook.id) }}"
    hx-boost="true"
    hx-target="#main"
  >
    Logs
  </a>
</div>
{% endmacro %}

{{
  datatable.datatable(
    webhooks,
    count,
    datatable_query_parameters,
    "Webhooks",
    columns | map("get_column_macro") | list,
  )
}}
