Files
rm-circle-team-router/public/nav-dash.js
T
martbost 8262b382e6 Navigation audit fixes: duplicates, mobile invisibility, and two dead ends
Ran a signed-in walkthrough of 23 pages at desktop and mobile widths. Three
real problems.

1. ELEVEN Suite pages showed "My Dashboard" TWICE — they ship their own
   button and nav-dash.js injected a second one. It now bails if a /my link
   is already present.

2. The Suite link was hide-mobile, so on a phone — where most members are —
   the toolkit was invisible on every page except the dashboard. That is
   precisely backwards for the tool we just launched to the whole org. It is
   now visible at every width.

3. Fast Start and Weekly Rhythm had NO navigation at all and an unclickable
   brand mark: a member landing there was stuck with the browser back button.
   They are PRINT sheets, so bolting the site header on would have wrecked
   what they are for — they now carry a small screen-only bar that is hidden
   by @media print.

Printable Handouts and Generation Pay were also missing the Suite link; they
pick it up from nav-dash now that it is no longer hidden on mobile.

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

45 lines
2.0 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';
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;
// Several pages already ship their own dashboard button. Injecting a
// second one gave members two identical links side by side.
if (nav.querySelector('a[href^="/my"]')) 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(); });
})();