account: fix duplicate billing line + always show badge for founding members

Duplicate "Lifetime · Never billed again" was caused by
insertAdjacentHTML('afterend') appending another <p> on every
renderPlanCard call - and renderPlanCard runs both in init() and on
the onAuthStateChange INITIAL_SESSION event, so the line stacks.
Replaced with a dedicated #plan-billing-note-el container that
setHtml() replaces in place.

Badge: collapsed the two-branch fetch into one path. Founding
members now always see the badge; if member_number is set we render
"#N", otherwise we fall through to "Your number awaits" via the
existing n=0 endpoint behaviour.
This commit is contained in:
Will Anderson
2026-05-01 23:51:13 -05:00
parent eea9ff8ff4
commit 04f3afea09
+8 -23
View File
@@ -718,6 +718,7 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String {
<div>
<p class=\"plan-name\" id=\"plan-name-el\">Loading...</p>
<div id=\"plan-status-el\"></div>
<div id=\"plan-billing-note-el\"></div>
</div>
</div>
<div class=\"plan-meta\" id=\"plan-meta-el\"></div>
@@ -1029,7 +1030,7 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String {
}
setHtml('plan-status-el', statusHtml);
// Billing note below status
// Billing note (replaces, never appends - this function may run more than once on auth state changes)
var billingNote = '';
if (plan === 'founding') {
billingNote = '<p class=\"plan-billing-note\">Lifetime &middot; Never billed again</p>';
@@ -1038,8 +1039,7 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String {
} else {
billingNote = '<p class=\"plan-billing-note\">On the waitlist</p>';
}
var statusEl = document.getElementById('plan-status-el');
if (statusEl) statusEl.insertAdjacentHTML('afterend', billingNote);
setHtml('plan-billing-note-el', billingNote);
// Meta
var meta = '';
@@ -1055,31 +1055,16 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String {
setHtml('plan-meta-el', meta);
}
// Founding badge
if (plan === 'founding' && memberNum) {
// Founding badge - always show for founding members, with member number if assigned
if (plan === 'founding') {
var badgeSection = document.getElementById('badge-section');
var badgeContainer = document.getElementById('badge-html-container');
if (badgeSection && badgeContainer) {
badgeSection.style.display = '';
// Fetch badge HTML from server
fetch('/api/founding-badge?n=' + memberNum)
.then(function(r) { return r.text(); })
.then(function(html) {
badgeContainer.innerHTML = html;
})
.catch(function(e) {
console.error('Failed to load badge:', e);
});
}
} else if (plan === 'founding') {
// Founding member but number not yet assigned
var badgeSection = document.getElementById('badge-section');
if (badgeSection) badgeSection.style.display = '';
fetch('/api/founding-badge?n=0')
var badgeN = memberNum || 0;
fetch('/api/founding-badge?n=' + badgeN)
.then(function(r) { return r.text(); })
.then(function(html) {
var c = document.getElementById('badge-html-container');
if (c) c.innerHTML = html;
if (badgeContainer) badgeContainer.innerHTML = html;
})
.catch(function() {});
}