feat(пополнение): кнопка и окно суммы в чате, ссылка на /stats, колонки и возврат в админке

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
anor
2026-10-28 14:57:27 +10:00
co-authored by Claude Opus 5.5
parent 289ce1ff1e
commit a157d9151c
4 changed files with 195 additions and 16 deletions
+18 -3
View File
@@ -55,6 +55,7 @@ td.bar-cell { width: 38%; }
.bar { height: 10px; border-radius: 5px; background: var(--bar); min-width: 2px; }
.bar.zero { background: var(--border); }
.bad { color: var(--accent); font-weight: 600; }
.topup-link { display: inline-block; margin: .5rem 0; padding: .45rem .9rem; background: var(--accent, #c4463a); color: #fff; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: .9rem; }
.deposits { list-style: none; margin-top: .4rem; font-variant-numeric: tabular-nums; }
.deposits li { padding: .2rem 0; border-bottom: 1px solid var(--border-light); font-size: .9rem; }
.state { padding: 1.5rem 0; text-align: center; color: var(--text-muted); }
@@ -210,10 +211,21 @@ function renderBalance(b) {
// Счёт (предоплата). «Списано со счёта» — по цене под ответами с первого взноса, а карточка
// «Потрачено за всё время» — вся история по нынешней цене: подписи разные, чтобы человек
// не складывал одно с другим.
function renderAccount(acc, deposits, readOnly) {
function topupLink() {
const a = el('a', 'topup-link', 'Пополнить счёт');
a.href = '/?topup=1';
return a;
}
function renderAccount(acc, deposits, readOnly, topup) {
const sec = document.getElementById('account');
const box = document.getElementById('account-body');
box.textContent = '';
if (!acc && topup) {
box.append(el('p', 'muted', 'Счёт ещё не пополнялся.'), topupLink());
sec.hidden = false;
return;
}
if (!acc) { sec.hidden = true; return; }
const since = new Date(acc.since * 1000).toLocaleDateString('ru-RU');
box.append(el('p', 'balance-line', 'На счёте: ' + rub(acc.balance_rub)));
@@ -221,8 +233,10 @@ function renderAccount(acc, deposits, readOnly) {
': ' + rub(acc.charged_rub)));
// Исчерпан — это уже сказано в блоке «Баланс» (read_only); второй раз не повторяем.
if (acc.exhausted && !readOnly) {
box.append(el('p', 'bad', 'Баланс исчерпан: новые вопросы закрыты до пополнения. Напишите на info@infosmeta.ru.'));
box.append(el('p', 'bad', 'Баланс исчерпан: новые вопросы закрыты до пополнения.' +
(topup ? '' : ' Напишите на info@infosmeta.ru.')));
}
if (topup) box.append(topupLink());
if (deposits && deposits.length) {
box.append(el('p', 'muted', 'Пополнения:'));
const ul = el('ul', 'deposits');
@@ -279,7 +293,8 @@ async function load() {
un.hidden = !s.unpriced;
if (s.unpriced) un.textContent = 'Цена ещё не посчитана у ' + s.unpriced + ' ответ(ов) — они в итог не вошли.';
renderBalance(res.body.limits || {});
renderAccount((res.body.limits || {}).account, res.body.deposits, (res.body.limits || {}).read_only);
renderAccount((res.body.limits || {}).account, res.body.deposits, (res.body.limits || {}).read_only,
(res.body.limits || {}).topup);
renderDays(s.days);
document.getElementById('state').hidden = true;
document.getElementById('content').hidden = false;