Stop the invite being lost when a prospect clicks through the nav

Terry hit this: he shares /join/840, his prospect taps "Training" in the
nav, and by the time they reach /start the site has forgotten him and
offers the COMPANY rotation position — #148. His referral, handed to a
stranger, because the prospect read the training first.

The invite now outlives the page it landed on:

- Serving /join/<id> sets an rmc_ref cookie (30 days, Lax).
- /start reads it (or an explicit ?ref=) and shows the INVITER instead of
  the company rotation, routed by exactly the same rules the inviter's own
  page uses — direct placement if their position is set that way, else the
  next open spot in their leg. The two pages can no longer disagree.
- The Join button carries ?ref through to /join-now, which already knew how
  to place a ref correctly but was never being given one from here.
- /join-now also falls back to the cookie when it arrives with no ?ref.

The page now says whose team it is ("Invited by Member #840") rather than
an anonymous "current placement", and when the inviter is already
qualified it says plainly that the entry fills the next open spot in their
team.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-18 11:18:23 -05:00
parent 25b3636352
commit 2b36a29a68
3 changed files with 63 additions and 5 deletions
+4
View File
@@ -55,6 +55,10 @@ fetch('/api/public/config').then(function(r){return r.json()}).then(function(c){
// personal invite: ?ref=<id> -> place in that member's leg via the site's moving-link joinTarget
var qp=new URLSearchParams(location.search);
var ref=qp.get('ref');
// No ?ref on the URL? Fall back to the invite cookie set when this visitor landed on
// someone's /join/<id> page. Without this a prospect who wandered through the nav
// enrolled under the company rotation and the inviter lost the referral.
if(!ref){ try{ var ck=document.cookie.match(/(?:^|;\s*)rmc_ref=(\d{1,15})/); if(ck)ref=ck[1]; }catch(e){} }
// Direct link (?direct=1): opt out of rotation — register straight under
// the inviter (spillover in their team), never the next-to-qualify member.
if(ref&&/^\d{1,15}$/.test(ref)&&qp.get('direct')==='1'){