Files
shop10/src/views/admin/orders.ejs
T

54 lines
1.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%- include('../partials/layout-start') %>
<div class="admin-header">
<h1>Заказы</h1>
<nav class="admin-nav">
<a href="/admin" class="admin-nav__link">Обзор</a>
<a href="/admin/orders" class="admin-nav__link admin-nav__link--active">Заказы</a>
<a href="/admin/users" class="admin-nav__link">Пользователи</a>
<a href="/admin/products" class="admin-nav__link">Товары</a>
<a href="/" class="admin-nav__link">В магазин</a>
</nav>
</div>
<% const statusLabels = { pending: 'Ожидает', paid: 'Оплачен', shipped: 'Отправлен', cancelled: 'Отменён' }; %>
<table class="cart-table">
<thead>
<tr>
<th>№</th>
<th>Клиент</th>
<th>Статус</th>
<th>Сумма</th>
<th>Дата</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
<% orders.forEach(o => { %>
<tr>
<td>#<%= o.id %></td>
<td>
<%= o.customer_name %><br>
<span class="muted"><%= o.customer_email %></span>
</td>
<td><span class="status status--<%= o.status %>"><%= statusLabels[o.status] || o.status %></span></td>
<td><%= formatPrice(o.total_cents) %></td>
<td><%= new Date(o.created_at).toLocaleString('ru-RU') %></td>
<td>
<form method="post" action="/admin/orders/<%= o.id %>/status" class="inline-form admin-status-form">
<select name="status" class="input input--sm">
<% ['pending','paid','shipped','cancelled'].forEach(s => { %>
<option value="<%= s %>" <%= o.status === s ? 'selected' : '' %>><%= statusLabels[s] %></option>
<% }) %>
</select>
<button type="submit" class="btn btn--ghost btn--sm">OK</button>
</form>
</td>
</tr>
<% }) %>
</tbody>
</table>
<%- include('../partials/layout-end') %>