// Admin: status, the L2 sign-up checks (release / reject / recheck), the pending-rewards ledger, and (staging only) the test-member switch. // The token stays in this tab only (sessionStorage). (function () { const $ = VAS.$, esc = VAS.esc; let tok = ''; try { tok = sessionStorage.getItem('vas.admin') || ''; } catch (e) {} const H = () => ({ 'x-admin-token': tok, 'Content-Type': 'application/json' }); const api = (p, body) => VAS.getJSON(p, body ? { method: 'POST', headers: H(), body: JSON.stringify(body) } : { headers: H() }); async function load() { if (!tok) return; const s = await api('/api/admin/status'); $('statusOut').textContent = JSON.stringify(s, null, 2); $('testBox').hidden = !s.testSwitch; const su = await api('/api/admin/signups'); $('suRows').innerHTML = (su.signups || []).map(x => '' + esc(x.id) + '' + esc(x.status) + '' + esc(x.email) + (x.confirmLink ? '
staging confirm link' : '') + '' + esc(x.resharer || '') + '' + esc(JSON.stringify(x.checks || {})) + (x.fail.length ? '
fail: ' + esc(x.fail.join(', ')) : '') + (x.hold.length ? '
hold: ' + esc(x.hold.join(', ')) : '') + ' ').join('') || 'none'; const rw = await api('/api/admin/rewards'); $('rwRows').innerHTML = (rw.rewards || []).map(r => '' + esc(r.id) + '' + esc(r.toName || r.to) + '' + esc(r.kind) + '' + esc(r.cents) + '' + esc(r.status) + '' + (r.voucher ? 'signed, nonce ' + esc(String(r.voucher.nonce).slice(0, 10)) + '...' : esc(r.note || '')) + '').join('') || 'none'; } document.addEventListener('click', async e => { const b = e.target.closest('button[data-a]'); if (!b) return; const r = await api('/api/admin/signup', { id: b.dataset.id, action: b.dataset.a }); if (r.error) VAS.status(r.error, 'err'); load(); }); $('go').onclick = () => { tok = $('tok').value.trim(); try { sessionStorage.setItem('vas.admin', tok); } catch (x) {} load(); }; $('tGo').onclick = async () => { const r = await api('/api/admin/test-member', { address: $('tAddr').value.trim(), username: $('tName').value.trim() || undefined }); VAS.status(r.error || 'Marked as a test member.', r.error ? 'err' : 'ok'); }; load(); })();