Files
rm-circle-team-router/public/nav-dash.js
T
martbost b5cb63f15c Add a Suite link to the member nav — it was unreachable
The Circle Suite went live to all 216 positions, but nothing outside its own
pages linked to it. Members could only reach it by knowing the URL, which
means most of them could not reach it at all.

The dashboard now leads with it: "My Tools" is the primary action, and Promo
Tools drops to secondary — the Promo Center is itself a level-1 Suite tool, so
the Suite is its parent rather than its sibling.

Everywhere else it rides the existing nav-dash.js injection, which already
runs on every member page and already knows who the visitor is. Same identity
test as the dashboard button: if we know who they are, they hold a position,
and a position is a licence to the toolkit. Prospects still see nothing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-29 06:33:30 -05:00

42 lines
1.8 KiB
JavaScript

// "My Dashboard" shortcut in the top-right nav. Appears when we know who the
// visitor is: an authenticated msg session (web wallet sign-in OR the Telegram
// Mini App auth bridge) is authoritative; otherwise the last dashboard opened
// on this device (ctb.myId, set by my.js) or the tools-page ID. No identity →
// no button, so prospects never see it.
(function () {
'use strict';
if (/^\/my(\/|$)/.test(location.pathname)) return;
var nav = document.querySelector('.nav-actions');
if (!nav) return;
// The Suite went live to the whole org but nothing outside its own pages
// linked to it, so members could only reach it by knowing the URL. Same
// identity test as the dashboard button: if we know who they are, they hold
// a position, and a position is a licence to the toolkit.
function addSuite() {
if (/^\/suite(\/|$)/.test(location.pathname)) return;
if (nav.querySelector('a[href="/suite"]')) return;
var a = document.createElement('a');
a.className = 'btn btn-secondary hide-mobile';
a.href = '/suite';
a.textContent = '🧰 My Tools';
nav.insertBefore(a, nav.firstChild);
}
function add(id) {
if (!id || !/^\d{1,15}$/.test(String(id))) return;
if (document.getElementById('navMyDash')) return;
var a = document.createElement('a');
a.id = 'navMyDash';
a.className = 'btn btn-secondary';
a.href = '/my/' + id;
a.textContent = '📊 My Dashboard';
nav.insertBefore(a, nav.firstChild);
}
var stored = null;
try { stored = localStorage.getItem('ctb.myId') || localStorage.getItem('rmc.toolsId'); } catch (e) {}
fetch('/api/public/msg-me')
.then(function (r) { return r.ok ? r.json() : null; })
.then(function (d) { var id = d && d.id ? d.id : stored; add(id); if (id) addSuite(); })
.catch(function () { add(stored); if (stored) addSuite(); });
})();