{include file="_partials/head.tpl"}

<div class="page-head">
  <div>
    <h1>Комментарии <span class="muted" style="font-weight:400">· {pagination.total}</span></h1>
  </div>
</div>

<div class="tabs-bar">
  <a href="/admin/comments" class="tab [if {current_filter}=""]is-active[/if]">Все</a>
  <a href="/admin/comments?status=pending"  class="tab [if {current_filter}="pending"]is-active[/if]"><span class="tab-dot tab-dot-pending"></span>Ожидают</a>
  <a href="/admin/comments?status=approved" class="tab [if {current_filter}="approved"]is-active[/if]"><span class="tab-dot tab-dot-approved"></span>Одобренные</a>
  <a href="/admin/comments?status=spam"     class="tab [if {current_filter}="spam"]is-active[/if]"><span class="tab-dot tab-dot-spam"></span>Спам</a>
</div>

[if {comments}]
<div class="prod-table-wrap">
<table class="table prod-table">
  <thead>
    <tr>
      <th>Автор</th>
      <th>Комментарий</th>
      <th>К чему</th>
      <th>Статус</th>
      <th class="actions"></th>
    </tr>
  </thead>
  <tbody>
    [foreach var="comments" as="c"]
      <tr class="cmt-row cmt-row-{c.status}">
        <td>
          <div class="cmt-author">{c.author_name}</div>
          <small class="muted">{c.author_email}</small>
        </td>
        <td class="cmt-body-cell">{c.body}</td>
        <td class="muted"><small>{c.entity_type} #{c.entity_id}</small></td>
        <td><span class="badge badge-{c.status}">{c.status}</span></td>
        <td class="actions cmt-actions">
          [if {c.status}="approved"]
            <form method="post" action="/admin/comments/{c.id}/status" class="cmt-act">
              {csrf}<input type="hidden" name="status" value="pending">
              <button type="submit" class="btn btn-ghost btn-sm" title="Отозвать одобрение">{icon name="arrow_left" size="14"} В ожидание</button>
            </form>
          [else]
            <form method="post" action="/admin/comments/{c.id}/status" class="cmt-act">
              {csrf}<input type="hidden" name="status" value="approved">
              <button type="submit" class="btn btn-primary btn-sm">{icon name="check" size="14"} Одобрить</button>
            </form>
          [/if]

          [if {c.status}="spam"]
            <form method="post" action="/admin/comments/{c.id}/status" class="cmt-act">
              {csrf}<input type="hidden" name="status" value="pending">
              <button type="submit" class="btn btn-ghost btn-sm" title="Убрать пометку «спам»">{icon name="arrow_left" size="14"} Не спам</button>
            </form>
          [else]
            <form method="post" action="/admin/comments/{c.id}/status" class="cmt-act">
              {csrf}<input type="hidden" name="status" value="spam">
              <button type="submit" class="btn btn-ghost btn-sm" title="Пометить как спам">{icon name="flag" size="14"} Спам</button>
            </form>
          [/if]

          <form method="post" action="/admin/comments/{c.id}/delete" class="cmt-act"
                data-confirm="Удалить комментарий безвозвратно?" data-confirm-danger="1">
            {csrf}
            <button type="submit" class="row-icon-btn row-icon-danger" title="Удалить">{icon name="trash" size="14"}</button>
          </form>
        </td>
      </tr>
    [/foreach]
  </tbody>
</table>
</div>
{include file="_partials/pagination.tpl"}
[else]
<div class="empty-state">
  {icon name="comments" size="42"}
  <p>Комментариев пока нет.</p>
</div>
[/if]

{include file="_partials/foot.tpl"}
