refactor(shop): убрать дублирующее «Начислить монеты» из вкладки Магазин
Начисление монет осталось в «Пользователях» (быстрое действие quickAwardCoins) и во вкладке «Геймификация». Из магазина удалены: HTML-блок «Начислить монеты», функции shopSearchUser/shopPickUser/shopAdminAwardCoins, их window-экспорты и неиспользуемые стейт-переменные. Эндпоинт /shop/admin/award-coins не тронут — им пользуется quickAwardCoins. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1387,27 +1387,6 @@
|
||||
<button class="adm-btn" style="background:var(--border-h);color:var(--text-3)" onclick="shopAdminCancelForm()">Отмена</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-title" style="margin-top:32px">Начислить монеты</div>
|
||||
<div class="adm-panel">
|
||||
<div class="adm-form-row">
|
||||
<div class="adm-form-group adm-user-search" style="flex:1">
|
||||
<label>Пользователь</label>
|
||||
<input type="text" id="shop-award-user" placeholder="Поиск по имени…" autocomplete="off" oninput="shopSearchUser(this.value)" />
|
||||
<div class="us-results" id="shop-award-results"></div>
|
||||
<input type="hidden" id="shop-award-uid" />
|
||||
</div>
|
||||
<div class="adm-form-group" style="width:120px">
|
||||
<label>Кол-во монет</label>
|
||||
<input type="number" id="shop-award-amount" min="1" value="10" />
|
||||
</div>
|
||||
<div class="adm-form-group" style="flex:1">
|
||||
<label>Причина</label>
|
||||
<input type="text" id="shop-award-reason" placeholder="За активность" />
|
||||
</div>
|
||||
<button class="adm-btn adm-btn-primary" onclick="shopAdminAwardCoins()" style="align-self:flex-end">Начислить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Геймификация ── -->
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
'use strict';
|
||||
/* admin → shop section: items + purchases + award coins */
|
||||
/* admin → shop section: items + purchases */
|
||||
(function () {
|
||||
'use strict';
|
||||
let inited = false;
|
||||
let _shopItems = [];
|
||||
let _shopEditId = null;
|
||||
let _shopSaving = false;
|
||||
let _shopSearchTimer = null;
|
||||
let _coinsAwarding = false;
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
@@ -156,46 +154,6 @@
|
||||
} catch(e) { LS.toast('Ошибка: ' + e.message, 'error'); }
|
||||
}
|
||||
|
||||
async function shopSearchUser(q) {
|
||||
clearTimeout(_shopSearchTimer);
|
||||
const box = document.getElementById('shop-award-results');
|
||||
if (q.length < 2) { box.classList.remove('open'); return; }
|
||||
_shopSearchTimer = setTimeout(async () => {
|
||||
try {
|
||||
const r = await LS.adminGetUsers({ q, limit: 8 });
|
||||
const label = u => u.name || u.email;
|
||||
box.innerHTML = (r.users || []).map(u => `<div class="us-item" data-uid="${u.id}" data-name="${esc(label(u))}" onclick="shopPickUser(this)">
|
||||
<span>${esc(label(u))}</span><span class="us-role">${esc(u.role)}</span>
|
||||
</div>`).join('') || '<div class="us-item" style="color:var(--text-3)">Не найдено</div>';
|
||||
box.classList.add('open');
|
||||
} catch(e) { box.classList.remove('open'); }
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function shopPickUser(el) {
|
||||
document.getElementById('shop-award-uid').value = el.dataset.uid;
|
||||
document.getElementById('shop-award-user').value = el.dataset.name || '';
|
||||
document.getElementById('shop-award-results').classList.remove('open');
|
||||
}
|
||||
|
||||
async function shopAdminAwardCoins() {
|
||||
if (_coinsAwarding) return;
|
||||
const userId = parseInt(document.getElementById('shop-award-uid').value);
|
||||
const amount = parseInt(document.getElementById('shop-award-amount').value);
|
||||
const reason = document.getElementById('shop-award-reason').value.trim();
|
||||
if (!userId) { LS.toast('Выберите пользователя', 'error'); return; }
|
||||
if (!amount || amount <= 0) { LS.toast('Введите количество монет', 'error'); return; }
|
||||
_coinsAwarding = true;
|
||||
try {
|
||||
const r = await LS.adminShopAwardCoins({ userId, amount, reason });
|
||||
LS.toast(`Начислено ${amount} монет. Баланс: ${r.coins}`, 'success');
|
||||
document.getElementById('shop-award-uid').value = '';
|
||||
document.getElementById('shop-award-user').value = '';
|
||||
document.getElementById('shop-award-reason').value = '';
|
||||
} catch(e) { LS.toast('Ошибка: ' + e.message, 'error'); }
|
||||
finally { _coinsAwarding = false; }
|
||||
}
|
||||
|
||||
// Expose onclick handlers
|
||||
window.shopAdminCreateItem = shopAdminCreateItem;
|
||||
window.shopAdminEditItem = shopAdminEditItem;
|
||||
@@ -203,9 +161,6 @@
|
||||
window.shopAdminSaveItem = shopAdminSaveItem;
|
||||
window.shopAdminDeleteItem = shopAdminDeleteItem;
|
||||
window.shopAdminToggleActive = shopAdminToggleActive;
|
||||
window.shopSearchUser = shopSearchUser;
|
||||
window.shopPickUser = shopPickUser;
|
||||
window.shopAdminAwardCoins = shopAdminAwardCoins;
|
||||
|
||||
window.AdminSections = window.AdminSections || {};
|
||||
window.AdminSections.shop = {
|
||||
|
||||
Reference in New Issue
Block a user