// My Spots + dashboard: wallet signature sign-in, per-spot image + link editing, default creative, payouts, directs. (async function () { await BL.renderNav('/my'); BL.renderFooter(); const $ = BL.$, esc = BL.esc; const ROLE = { 0: 'sponsor share', 1: 'line level', 2: 'company A', 3: 'company B', 4: 'fund' }; const KIND = { 0: 'paid', 1: 'bought for you', 2: 'fund gift', 3: 'fund kept' }; const c = await BL.getConfig(); const me = await BL.getJSON('/api/me'); if (!me.signedIn) { $('signin').hidden = false; $('signBtn').onclick = async () => { try { BL.status('Check your wallet for the sign-in message.'); await BLWallet.signIn(); location.reload(); } catch (e) { BL.status(String(e && e.message || e).slice(0, 300), 'err'); } }; return; } $('outBtn').onclick = async () => { await BL.post('/api/auth/logout'); location.reload(); }; async function load() { const d = await BL.getJSON('/api/my'); if (d.error) return BL.status(d.error, 'err'); $('dash').hidden = false; $('me').textContent = d.address; const delivered = d.spots.reduce((t, s) => t + s.views, 0); $('stats').innerHTML = [['Spots owned', d.spots.length], ['Views delivered', delivered + ' of ' + d.spots.filter(s => s.kind !== 3).length * c.viewsOwed], ['POL paid in', BL.fmtPol(d.paidInWei)], ['POL paid out to you', BL.fmtPol(d.paidOutWei)]] .map(x => '
You have no spots yet. Get one.
'; for (const s of d.spots) box.appendChild(editor('spot', s)); $('defaults').innerHTML = ''; $('defaults').appendChild(editor('default', { img: d.defaults.img || '', link: d.defaults.link || '', showing: { img: d.defaults.img || '/art/house-line.svg' } })); $('payouts').innerHTML = d.payouts.length ? '| Spot sold | Why | POL | Tx |
|---|---|---|---|
| #' + p.spotId + ' | ' + esc(ROLE[p.role] || p.role) + ' | ' + BL.fmtPol(p.amount, 6) + ' | ' + txLink(p.tx) + ' |
No payments yet. You are paid when spots sell after yours, or when someone you referred buys.
'; $('directs').innerHTML = d.directs.length ? '| Member | Joined | Spots | Paid spots | POL paid in |
|---|---|---|---|---|
| ' + esc(BL.short(m.address)) + ' | ' + new Date(m.joinedAt).toLocaleDateString() + ' | ' + m.spots + ' | ' + m.paidSpots + ' | ' + BL.fmtPol(m.paidInWei) + ' |
Nobody has joined through your link yet.
'; } const txLink = h => c.explorer ? '' + esc(h.slice(0, 10)) + '...' : esc(h.slice(0, 10)) + '...'; function editor(kind, s) { const el = document.createElement('div'); el.className = 'spot-ed'; const head = kind === 'spot' ? '