feat(админка): ручной взнос v2 с идемпотентностью

This commit is contained in:
anor
2026-11-06 22:18:45 +10:00
parent 19834cd1dc
commit 99b62fb5fb
6 changed files with 207 additions and 0 deletions
+13
View File
@@ -68,6 +68,18 @@ export function CustomerDrawer({ email, onClose, onDeleted, onChanged }) {
} catch (e) { setNotice(e.message || 'Не удалось отменить'); }
finally { setBusy(false); }
};
const topup = async () => {
const amount = prompt('Сумма взноса, ₽', '1000');
if (!amount) return;
setBusy(true); setNotice('');
try {
const rid = (crypto && crypto.randomUUID) ? crypto.randomUUID() : String(Date.now());
await api('/api/admin/v2/customers/' + encodeURIComponent(email) + '/topup',
{method: 'POST', body: JSON.stringify({amount, request_id: rid})});
setNotice('Взнос записан'); setReload((n) => n + 1);
} catch (e) { setNotice(e.message || 'Взнос не записан'); }
finally { setBusy(false); }
};
const del = async () => {
if (!confirm('Удалить учётку ' + email + '? Переписка и файлы останутся, адрес освободится.')) return;
setBusy(true); setNotice('');
@@ -109,6 +121,7 @@ export function CustomerDrawer({ email, onClose, onDeleted, onChanged }) {
<button type="button" disabled=${busy} onClick=${() => act('agent_access',
{agent_access: !card.profile.agent_access}, card.profile.agent_access ? 'Доступ снят' : 'Доступ выдан')}>
${card.profile.agent_access ? 'Снять агента' : 'Выдать агента'}</button>
<button type="button" disabled=${busy} onClick=${topup}>Внести</button>
<button type="button" disabled=${busy} onClick=${del}>Удалить</button>
</div>` : html`<div class="actions-bar">
<button type="button" disabled=${busy} onClick=${restore}>Восстановить</button>