feat: подписка на уведомление о поступлении товара

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 13:38:03 +03:00
parent 561fbd22e0
commit e2a7c79245
11 changed files with 313 additions and 2 deletions
+20 -1
View File
@@ -12,6 +12,12 @@
</nav>
</div>
<% if (stockUpdated) { %>
<p class="alert alert--success">
Остаток обновлён.<% if (notified > 0) { %> Отправлено уведомлений подписчикам: <%= notified %>.<% } %>
</p>
<% } %>
<table class="cart-table">
<thead>
<tr>
@@ -20,6 +26,7 @@
<th>Категория</th>
<th>Цена</th>
<th>Остаток</th>
<th>Подписки</th>
<th></th>
</tr>
</thead>
@@ -30,7 +37,19 @@
<td><%= p.name %></td>
<td><%= p.category_name || '—' %></td>
<td><%= formatPrice(p.price_cents) %></td>
<td><%= p.stock %></td>
<td>
<form action="/admin/products/<%= p.id %>/stock" method="post" class="inline-form admin-stock-form">
<input type="number" name="stock" class="input input--sm" min="0" value="<%= p.stock %>" aria-label="Остаток">
<button type="submit" class="btn btn--ghost btn--sm">OK</button>
</form>
</td>
<td>
<% if (p.alert_count > 0) { %>
<span class="badge" title="Ждут уведомления"><%= p.alert_count %></span>
<% } else { %>
<% } %>
</td>
<td><a href="/product/<%= p.slug %>">На сайте</a></td>
</tr>
<% }) %>
+27
View File
@@ -18,6 +18,8 @@
<p class="product-detail__stock">В наличии: <strong><%= product.stock %></strong> шт.</p>
<% if (error) { %><p class="alert alert--error"><%= error %></p><% } %>
<% if (notifySuccess) { %><p class="alert alert--success"><%= notifySuccess %></p><% } %>
<% if (notifyError) { %><p class="alert alert--error"><%= notifyError %></p><% } %>
<% if (reserved) { %><p class="alert alert--success">Товар успешно забронирован. Подробности на почте и в личном кабинете.</p><% } %>
<% if (userReservation) { %>
<p class="alert alert--success">
@@ -52,6 +54,31 @@
<% } %>
<% } else { %>
<p class="alert alert--warn">Нет в наличии</p>
<% if (typeof cookieConsent !== 'undefined' && !cookieConsent) { %>
<p class="muted">Примите cookies, чтобы подписаться на уведомление о поступлении.</p>
<% } else if (stockAlertSubscribed) { %>
<p class="stock-notify stock-notify--done">
Вы подписаны на уведомление<% if (notifyEmail) { %> — письмо придёт на <strong><%= notifyEmail %></strong><% } %>.
</p>
<% } else { %>
<section class="stock-notify card">
<h2 class="stock-notify__title">Сообщить о поступлении</h2>
<p class="muted stock-notify__hint">Будьте среди первых, кто узнает, когда товар снова появится в наличии.</p>
<form action="/product/<%= product.slug %>/notify-stock" method="post" class="form stock-notify__form">
<% if (user && notifyEmail) { %>
<p class="muted">Уведомление отправим на <strong><%= notifyEmail %></strong></p>
<input type="hidden" name="email" value="<%= notifyEmail %>">
<% } else { %>
<label class="label">
Email
<input type="email" name="email" class="input" required autocomplete="email" placeholder="you@example.com" value="<%= notifyEmail || '' %>">
</label>
<% } %>
<button type="submit" class="btn btn--primary">Подписаться</button>
</form>
</section>
<% } %>
<% } %>
<a href="/" class="link-back">← Назад в каталог</a>
</div>