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

<div class="page-head">
  <div>
    <h1>{lang key="shop.reviews_list.title"} <span class="muted" style="font-weight:400">· {total}</span></h1>
    <p class="muted">{lang key="shop.reviews_list.subtitle"}</p>
  </div>
</div>

<div class="prod-tabs" style="margin-bottom:18px">
  <a href="/admin/shop/reviews?tab=all" class="prod-tab [if {tab}="all"]is-active[/if]">{lang key="shop.customers_list.tabs.all"} <span class="prod-tab-count">{tab_counts.all}</span></a>
  <a href="/admin/shop/reviews?tab=pending" class="prod-tab [if {tab}="pending"]is-active[/if]">На модерации <span class="prod-tab-count">{tab_counts.pending}</span></a>
  <a href="/admin/shop/reviews?tab=approved" class="prod-tab [if {tab}="approved"]is-active[/if]">Опубликованные <span class="prod-tab-count">{tab_counts.approved}</span></a>
</div>

[if {reviews}]
<div class="prod-table-wrap">
<table class="table prod-table">
  <thead>
    <tr>
      <th>{lang key="shop.reviews_list.col.product"}</th>
      <th>{lang key="shop.reviews_list.col.author"}</th>
      <th>{lang key="shop.reviews_list.col.rating"}</th>
      <th>{lang key="shop.reviews_list.col.text"}</th>
      <th>{lang key="shop.reviews_list.col.date"}</th>
      <th>{lang key="shop.products_list.col.status"}</th>
      <th class="actions"></th>
    </tr>
  </thead>
  <tbody>
    [foreach var="reviews" as="r"]
      <tr>
        <td>
          [if {r.product_slug}]<a href="/shop/product/{r.product_slug}" target="_blank" class="prod-title">{r.product_title}</a>
          [else]<span class="prod-title">{r.product_title}</span>[/if]
        </td>
        <td>{r.author_name}<br><small class="muted">{r.author_email}</small></td>
        <td>{r.rating} / 5</td>
        <td style="max-width:380px"><div style="white-space:pre-wrap;font-size:13px">{r.content}</div></td>
        <td><small class="muted">{r.created_at}</small></td>
        <td>[if {r.is_approved}]<span class="badge badge-published">{lang key="shop.reviews_list.published"}</span>[else]<span class="badge badge-draft">{lang key="shop.reviews_list.pending_state"}</span>[/if]</td>
        <td class="actions prod-row-actions">
          <form method="post" action="/admin/shop/reviews/{r.id}/approve" style="display:inline">
            {csrf}<button type="submit" class="btn btn-ghost btn-sm">[if {r.is_approved}]{lang key="shop.reviews_list.unapprove_short"}[else]{lang key="shop.reviews_list.approve_short"}[/if]</button>
          </form>
          <form method="post" action="/admin/shop/reviews/{r.id}/delete" style="display:inline" data-confirm="Удалить отзыв?" data-confirm-danger="1">
            {csrf}<button type="submit" class="row-icon-btn row-icon-danger" title="{lang key="shop.common.delete_title"}">{icon name="close" size="14"}</button>
          </form>
        </td>
      </tr>
    [/foreach]
  </tbody>
</table>
</div>
{include file="_partials/pagination.tpl"}
[else]
<div class="empty-state">
  <div class="icon">{icon name="comments" size="42"}</div>
  <p>{lang key="shop.reviews_list.empty.title"}</p>
</div>
[/if]

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