Split submissions into rotation vs leg paths — decided by the chain
Two leg-build members submitted the /start form thinking it was required, polluting rotation bookkeeping. Rather than two forms, the server now classifies every submission by on-chain truth: referrer == active rotation sponsor -> "rotation" (Telegram says +1 direct, add to queue); anyone else -> "leg" (correct sponsor credited, "no rotation action needed"). The member dashboard gains its own "Just joined under this position?" form so leg builders have a proper landing spot; /start feedback explains each path to the submitter; admin submissions table shows a rotation/leg chip. Verified against live data: ID 65 claiming sponsor 36 correctly classified leg under #62. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -136,6 +136,27 @@
|
||||
document.getElementById('idError').textContent=x.message;
|
||||
}
|
||||
}
|
||||
document.getElementById('dJoinForm').addEventListener('submit',async e=>{
|
||||
e.preventDefault();
|
||||
const form=e.currentTarget,msg=document.getElementById('dJoinMsg');
|
||||
const newId=form.elements.newId.value.trim(),memberName=form.elements.memberName.value.trim();
|
||||
if(!/^\d{1,10}$/.test(newId)){msg.style.color='var(--danger)';msg.textContent='Numbers only — the ID shown by the RM Circle dApp.';return}
|
||||
if(!memberName){msg.style.color='var(--danger)';msg.textContent='Add your name or Telegram handle.';return}
|
||||
msg.style.color='var(--muted)';msg.textContent='Verifying on the blockchain…';
|
||||
try{
|
||||
const pageId=(location.pathname.match(/^\/my\/(\d+)$/)||[])[1]||'?';
|
||||
const r=await fetch('/api/public/submit-id',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({newId,memberName,sponsorId:pageId,source:'dashboard-'+pageId,clickid:window.ctbGetClickId?window.ctbGetClickId():''})});
|
||||
const d=await r.json();
|
||||
if(!r.ok)throw new Error(d.error||'Submission failed');
|
||||
form.classList.add('hidden');
|
||||
msg.style.color='var(--ok)';
|
||||
const dash=`<br><a href="/my/${newId}" style="color:var(--gold)">Open your own dashboard →</a>`;
|
||||
if(d.duplicate)msg.innerHTML=`✓ ID <strong>${newId}</strong> was already submitted — you're on the list.${dash}`;
|
||||
else if(d.onchain&&d.onchain.registered)msg.innerHTML=`✓ Verified on the blockchain! ID <strong>${newId}</strong> is registered under sponsor <strong>#${d.onchain.referrerId}</strong> (${d.onchain.tier}). The team has been notified — welcome aboard.${dash}`;
|
||||
else if(d.path==='notfound'){msg.style.color='var(--danger)';msg.innerHTML=`⚠ ID <strong>${newId}</strong> isn't on the smart contract yet — double-check the number from the RM Circle dApp. Your submission is saved and the team will verify it manually.`;}
|
||||
else msg.innerHTML=`✓ Got it — submitted. The team will verify your placement.${dash}`;
|
||||
}catch(x){msg.style.color='var(--danger)';msg.textContent=x.message}
|
||||
});
|
||||
document.getElementById('idForm').addEventListener('submit',e=>{
|
||||
e.preventDefault();
|
||||
const v=document.getElementById('memberId').value.trim();
|
||||
|
||||
Reference in New Issue
Block a user