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:
Maxim Dolgolyov
2026-06-03 14:05:14 +03:00
parent 78a870ab70
commit 34c7886a41
2 changed files with 1 additions and 67 deletions
+1 -46
View File
@@ -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 = {