Visual downline tree on the Overview

"Your line at a glance": YOU + three levels of member chips with connectors,
your qualified directs highlighted in gold, and "+ open" placeholders on levels
1-2 showing what's next. Loads from /api/my/line.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-07 08:38:15 -05:00
parent 0dbd99f69e
commit 42d0e15fea
3 changed files with 40 additions and 2 deletions
+21
View File
@@ -285,6 +285,26 @@
if (toast) { IAP.status(toast, kind); if (sound) playSound(sound); liveRefresh(); }
}
// visual line tree on the Overview: YOU + three levels, qualified directs in gold
async function loadLineTree(buyerCount) {
try {
const r = await (await fetch('/api/my/line')).json();
const el = $('lineTree'); if (!el) return;
const levels = r.levels || [];
const total = levels.reduce((n, L) => n + L.members.length, 0);
if ($('treeSub')) $('treeSub').textContent = total ? total + ' across 3 levels' : 'share your link to grow';
const chip = (m, q) => '<span class="lt-node' + (q ? ' qualified' : (m.email ? '' : ' deep')) + '" title="' + esc(m.name || 'member') + (q ? ' · qualified buyer' : '') + '">' + esc(String(m.name || 'M').replace(/^@/, '').slice(0, 12)) + '</span>';
const rowFor = lvl => {
const L = levels.find(x => x.level === lvl); const members = L ? L.members : [];
const qn = lvl === 1 ? (buyerCount || 0) : 0; // highlight your qualified directs
let html = members.map((m, i) => chip(m, i < qn)).join('');
if (lvl <= 2 && members.length < (lvl === 1 ? 2 : 4)) html += '<span class="lt-node open">+ open</span>';
if (!html) html = '<span class="lt-node open">+ open</span>';
return '<div class="lt-row"><span class="lt-cap">L' + lvl + '</span><div class="lt-nodes">' + html + '</div></div>';
};
el.innerHTML = '<div class="lt-top"><span class="lt-you">YOU</span></div><div class="lt-stem"></div>' + rowFor(1) + rowFor(2) + rowFor(3);
} catch (e) {}
}
async function loadDashboard() {
try {
const d = await (await fetch('/api/my/dashboard')).json();
@@ -321,6 +341,7 @@
if (d.sponsorMsg) showSponsorModal(d.sponsorMsg);
renderBadges(d);
loadFeatured();
loadLineTree(d.buyerCount || 0);
loadCharts(d);
$('nextMove').textContent = nextMove(d);
renderSteps(d);