From 34c7886a41b3d9baa996ffdaaebd3b2aac66eb1f Mon Sep 17 00:00:00 2001 From: Maxim Dolgolyov Date: Wed, 3 Jun 2026 14:05:14 +0300 Subject: [PATCH] =?UTF-8?q?refactor(shop):=20=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D1=83=D0=B1=D0=BB=D0=B8=D1=80=D1=83=D1=8E?= =?UTF-8?q?=D1=89=D0=B5=D0=B5=20=C2=AB=D0=9D=D0=B0=D1=87=D0=B8=D1=81=D0=BB?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=BC=D0=BE=D0=BD=D0=B5=D1=82=D1=8B=C2=BB?= =?UTF-8?q?=20=D0=B8=D0=B7=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=9C=D0=B0=D0=B3=D0=B0=D0=B7=D0=B8=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Начисление монет осталось в «Пользователях» (быстрое действие quickAwardCoins) и во вкладке «Геймификация». Из магазина удалены: HTML-блок «Начислить монеты», функции shopSearchUser/shopPickUser/shopAdminAwardCoins, их window-экспорты и неиспользуемые стейт-переменные. Эндпоинт /shop/admin/award-coins не тронут — им пользуется quickAwardCoins. Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/admin.html | 21 ------------- frontend/js/admin/sections/shop.js | 47 +----------------------------- 2 files changed, 1 insertion(+), 67 deletions(-) diff --git a/frontend/admin.html b/frontend/admin.html index 9465084..feb9fc9 100644 --- a/frontend/admin.html +++ b/frontend/admin.html @@ -1387,27 +1387,6 @@ - -
Начислить монеты
-
-
- -
- - -
-
- - -
- -
-
diff --git a/frontend/js/admin/sections/shop.js b/frontend/js/admin/sections/shop.js index 31345d3..bd18b57 100644 --- a/frontend/js/admin/sections/shop.js +++ b/frontend/js/admin/sections/shop.js @@ -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 => `
- ${esc(label(u))}${esc(u.role)} -
`).join('') || '
Не найдено
'; - 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 = {