feat(админка): возврат в чат из шапки и открытие диалогов пользователей

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-11 16:39:39 +10:00
co-authored by Claude Code
parent fd253de8a5
commit ae5386a5a6
7 changed files with 172 additions and 5 deletions
+2 -1
View File
@@ -71,7 +71,8 @@ const App = () => {
<div class="side-foot">v.${version || '—'}</div>
</nav>
<main class="main">
<header class="top"><div><h1 tabIndex="-1">${title}</h1><p>${subtitle}</p></div></header>
<header class="top"><div><h1 tabIndex="-1">${title}</h1><p>${subtitle}</p></div>
<a class="back-to-chat" href="/">← Вернуться в чат</a></header>
${section === 'today' ? html`<${DayPage} />`
: section === 'customers' ? html`<${CustomersPage} />`
: section === 'money' ? html`<${MoneyPage} />`
+14 -2
View File
@@ -44,7 +44,7 @@ export function CustomerDrawer({ email, onClose, onDeleted, onChanged }) {
const suffix = {dialogs: 'dialogs', ledger: 'ledger', files: 'files', history: 'history'}[tab];
setError(''); setLoading(true);
api('/api/admin/v2/customers/' + encodeURIComponent(email) + '/' + suffix)
.then((d) => { if (alive) setRows(d.items || d.entries || d); })
.then((d) => { if (alive) setRows(Array.isArray(d) ? d : (d.items || d.entries || [])); })
.catch((e) => { if (alive) setError(e.message || 'Не удалось загрузить вкладку'); })
.finally(() => { if (alive) setLoading(false); });
return () => { alive = false; };
@@ -148,7 +148,19 @@ export function CustomerDrawer({ email, onClose, onDeleted, onChanged }) {
<div><span>Был(а)</span><b>${when(card.activity.last_seen)}</b></div>
<div><span>Сообщений</span><b>${card.activity.messages}</b></div>
<div><span>Файлов</span><b>${card.activity.files}${card.activity.files_capped ? '+' : ''}</b></div>
</div>` : html`<div class="tab-body">${loading
</div>` : tab === 'dialogs' ? html`<div class="table-wrap">${loading
? html`<${Loading} rows={2} />`
: rows.length === 0 ? html`<p class="note">Пусто.</p>`
: html`<table><thead><tr><th>Был(а)</th><th class="num">Сообщений</th>
<th>Последний вопрос</th><th>Открыть</th></tr></thead>
<tbody>${rows.map((r) => html`
<tr key=${r.tab_id}><td>${when(r.last_ts)}</td><td class="num">${r.msg_count}</td>
<td>${String(r.title || r.last_question || '').slice(0, 120)}</td>
<td><a href=${'/?tab=' + encodeURIComponent(r.tab_id) +
'&owner=' + encodeURIComponent(email)} target="_blank"
rel="noopener noreferrer">Открыть</a></td>
</tr>`)}</tbody></table>`}</div>`
: html`<div class="tab-body">${loading
? html`<${Loading} rows={2} />`
: rows.length === 0 ? html`<p class="note">Пусто.</p>`
: html`<pre class="json">${JSON.stringify(rows.slice(0, 20), null, 2)}</pre>`}</div>`}
+3
View File
@@ -102,6 +102,9 @@ function DialogsTab() {
{key: 'last_question', label: 'Последний вопрос', render: (r) => String(r.last_question || '').slice(0, 120)},
{key: 'last_ts', label: 'Был(а)', render: (r) => new Date(r.last_ts * 1000).toLocaleString('ru-RU')},
{key: 'msg_count', label: 'Сообщений', num: true},
{key: 'open', label: 'Открыть', render: (r) => html`<a href=${'/?tab=' +
encodeURIComponent(r.tab_id) + '&owner=' + encodeURIComponent(r.username)}
target="_blank" rel="noopener noreferrer">Открыть</a>`},
]} />`;
}
+4
View File
@@ -18,6 +18,10 @@ body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.45 -apple-system
.main{flex:1;min-width:0;padding:22px 26px}
.top h1{margin:0 0 4px;font-size:22px}
.top p{margin:0 0 18px;color:var(--muted)}
.top{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.back-to-chat{font-size:13px;color:var(--muted);text-decoration:none;padding:6px 10px;
border:1px solid var(--line);border-radius:8px;white-space:nowrap;background:var(--card)}
.back-to-chat:hover{color:var(--accent);border-color:var(--accent)}
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:18px;max-width:760px}
.card h2{margin:0 0 6px;font-size:16px}
.card p{margin:0;color:var(--muted)}