// My Team (the coach's dashboard): stat tiles, instant picks left, the focused pick card (scouting stats, the getting-started // steps, one-tap messages, the message composer and thread, release), the rest of the team, who to help first, the draft queue. // Someone who is a pick sees their coach here instead (steps, the thread, the coach's builder links). Messages go through the // site only; no contact details are ever shown. Every figure comes from /api/my. (async function () { FX.renderNav('/team'); FX.renderFooter(); const $ = FX.$, esc = FX.esc; const c = await FX.getConfig().catch(() => ({})); const me = await FX.getJSON('/api/me'); if (!me.signedIn) { if (await FX.silentSso('/team')) return; $('signin').hidden = false; $('signinBox').innerHTML = FX.signInBlock('/team'); FX.wireSignIn($('signinBox')); return; } $('signout').hidden = false; $('signout').onclick = async () => { await FX.post('/api/auth/logout'); location.reload(); }; const pol = w => w == null ? 'not tracked yet' : FX.polOf(w) + ' POL'; let D = null, focus = null; const stat = (k, v, note) => '
No messages yet. Say hello: they see it in their member area.
'; async function load() { const d = await FX.getJSON('/api/my'); if (d.error) { FX.status(d.error, 'err'); return; } D = d; $('dash').hidden = false; $('hello').textContent = d.username ? '@' + d.username : FX.short(d.address); // a pick: their coach if (d.myCoach) { const mc = d.myCoach; $('myCoach').hidden = false; $('mcName').textContent = '@' + mc.coach; $('mcTier').textContent = mc.tierName + ' · on the team since ' + FX.when(mc.since); $('mcSteps').innerHTML = stepsHtml(mc.steps); $('mcThread').innerHTML = thread(mc.messages.map(x => ({ mine: x.dir === 'out', text: x.text, at: x.at }))); $('mcSend').onclick = async () => { const t = $('mcText').value.trim(); if (!t) return; const r = await FX.post('/api/my/message', { pick: mc.pickId, text: t }); if (r.error) return FX.status(r.error, 'err'); $('mcText').value = ''; load(); }; $('mcBuilder').innerHTML = mc.builder.slice(0, 8).map(p => '' + esc(p.name) + '').join(' ') || 'No builder links yet.'; } if (!d.coach && !d.picks.length) { $('noCoach').hidden = false; if (!d.myCoach) $('coachTools').hidden = true; return; } $('coachTools').hidden = false; const s = d.stats; $('stats').innerHTML = stat('On my team', s.onTeam, s.open + ' open of ' + s.maxOpen) + stat('Started this week', s.startedThisWeek, 'payouts on or a first purchase') + stat('Next draft spot', s.nextSpot ? '#' + s.nextSpot : '-', 'earned by this week\'s starts') + stat('Back to pool soon', s.backSoon, 'within 24 hours'); $('credits').hidden = !(d.credits > 0); $('creditsN').textContent = d.credits + ' instant pick' + (d.credits === 1 ? '' : 's'); if (d.page) { $('myPage').hidden = false; $('myPageLink').href = d.page; $('myPageLink').textContent = d.page.replace(/^https:\/\//, ''); } const team = d.picks.filter(p => ['open', 'done', 'kept'].includes(p.status)); if (!focus || !team.some(p => p.id === focus)) focus = (d.help[0] && d.help[0].pickId) || (team[0] && team[0].id) || null; paintFocus(team.find(p => p.id === focus)); const rest = team.filter(p => p.id !== focus); $('team').innerHTML = rest.length ? rest.map(p => '').join('') : '' + (team.length ? 'Nobody else on the team yet. ' : 'No picks yet. ') + (d.credits ? 'Use your instant picks on the Draft Board.' : 'Your next picks come in the Monday draft.') + '
'; document.querySelectorAll('[data-f]').forEach(b => b.onclick = () => { focus = Number(b.dataset.f); load(); }); $('help').innerHTML = d.help.length ? d.help.slice(0, 8).map(h => 'Nobody needs a nudge right now.
'; document.querySelectorAll('[data-f2]').forEach(b => b.onclick = () => { focus = Number(b.dataset.f2); load().then(() => $('focus').scrollIntoView({ behavior: 'smooth' })); }); const past = d.picks.filter(p => p.status === 'returned'); $('pastWrap').hidden = !past.length; $('past').innerHTML = past.slice(0, 12).map(p => '@' + esc(p.username || 'player') + '').join(' '); $('queue').innerHTML = d.queue.length ? '' + d.queue.length + ' player' + (d.queue.length === 1 ? '' : 's') + ' on your queue. If you are away when your pick comes up, the first one still available is drafted for you. Edit it on the Draft Board.
' : 'Your queue is empty: if you are away when your pick comes up, the best available player by scouting score is drafted for you. Add players from the Draft Board.
'; } async function paintFocus(p) { const el = $('focus'); if (!p) { el.hidden = true; return; } el.hidden = false; const label = p.kind === 'instant' ? 'INSTANT PICK' : 'ROUND ' + (p.round || '?') + ' PICK'; $('fKick').textContent = label + ' · ' + p.tierName.toUpperCase(); $('fName').textContent = '@' + (p.username || 'player'); $('fWhen').textContent = 'Picked ' + FX.when(p.at) + (p.status === 'open' ? ' · ' + (p.daysLeft ? p.daysLeft + ' day' + (p.daysLeft === 1 ? '' : 's') + ' left to start' : 'goes back to the pool today') : ' · started, stays on your team'); $('fStats').innerHTML = [['Game plays', p.plays == null ? 'not tracked yet' : FX.n(p.plays) + (p.game ? ' (' + p.game + ')' : '')], ['Earned in games', pol(p.gameWei)], ['Earned surfing', p.surfWei == null && p.surfCredits != null ? FX.n(p.surfCredits) + ' ad credits' : pol(p.surfWei)], ['Came from', p.door || 'not tracked yet'], ['Last seen', FX.ago(p.lastSeen)]] .map(r => '