Guest-invite form: keep a name field, optional and clearly labelled

Same standard form as the admin panel: the guest's email (required) plus
an OPTIONAL display name ('Their name (optional)' placeholder). Passed
through as the initial display name; an empty name is never derived from
the email. Full-width inputs in the stacked mobile form.
This commit is contained in:
inference-bot committed 2026-11-08 02:57:30 +00:00
1 parent 8f8106742a
commit e59ba4d05a
1 file changed
+14 -6
+14 -6
View File
@@ -630,9 +630,11 @@ PAGE_HTML = """<!DOCTYPE html>
/* ---------- Guest access (members inviting a friend) ---------- */ /* ---------- Guest access (members inviting a friend) ---------- */
.guest-hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; } .guest-hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
/* Standard guest-invite form (shared with the admin panel): ONE field. */ /* Standard guest-invite form (shared with the admin panel): email required,
name optional. */
.guest-invite-title { font-size: 14px; font-weight: 700; margin: 0 0 8px; } .guest-invite-title { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.new-key .name-input { max-width: 200px; }
.guest-trail { margin-top: 6px; } .guest-trail { margin-top: 6px; }
.guest-row { .guest-row {
display: flex; align-items: baseline; justify-content: space-between; gap: 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
@@ -670,6 +672,7 @@ PAGE_HTML = """<!DOCTYPE html>
.key-token { max-width: 100%; } .key-token { max-width: 100%; }
.new-key { flex-direction: column; } .new-key { flex-direction: column; }
.new-key button { width: 100%; } .new-key button { width: 100%; }
.new-key .name-input { max-width: none; } /* full-width in the stacked form */
.key-reveal-value { font-size: 11px; } .key-reveal-value { font-size: 11px; }
footer { padding: 16px 14px; } footer { padding: 16px 14px; }
footer a { display: inline-block; margin: 4px 8px; } footer a { display: inline-block; margin: 4px 8px; }
@@ -849,6 +852,8 @@ PAGE_HTML = """<!DOCTYPE html>
<form class="new-key" id="guest-invite-form" onsubmit="sendGuestInvite(event)"> <form class="new-key" id="guest-invite-form" onsubmit="sendGuestInvite(event)">
<label class="sr-only" for="guest-email">Their email</label> <label class="sr-only" for="guest-email">Their email</label>
<input id="guest-email" type="email" required placeholder="their@email.org" maxlength="254" autocomplete="off" inputmode="email" /> <input id="guest-email" type="email" required placeholder="their@email.org" maxlength="254" autocomplete="off" inputmode="email" />
<label class="sr-only" for="guest-name">Their name (optional)</label>
<input id="guest-name" type="text" class="name-input" placeholder="Their name (optional)" maxlength="80" autocomplete="off" />
<button class="primary" id="guest-btn" type="submit">Send invite</button> <button class="primary" id="guest-btn" type="submit">Send invite</button>
</form> </form>
<div class="hint" id="guest-allowance"></div> <div class="hint" id="guest-allowance"></div>
@@ -1021,13 +1026,15 @@ function renderGuests(d) {
}).join(''); }).join('');
} }
// The standard guest-invite form (ONE field: the guest's email). The inviter // The standard guest-invite form: the guest's email (required) plus an
// is the logged-in member — automatic, no field; the portal applies the // OPTIONAL display name. The inviter is the logged-in member — automatic, no
// member-side protections (active member, one per 30 days, recipient checks) // field; the portal applies the member-side protections (active member, one
// and, with the trial gate on, holds the request for approval. // per 30 days, recipient checks) and, with the trial gate on, holds the
// request for approval. An empty name is never derived from the email.
async function sendGuestInvite(ev) { async function sendGuestInvite(ev) {
if (ev) ev.preventDefault(); if (ev) ev.preventDefault();
const email = ($('guest-email').value || '').trim(); const email = ($('guest-email').value || '').trim();
const name = ($('guest-name').value || '').trim();
const btn = $('guest-btn'); const btn = $('guest-btn');
const label = btn.textContent; const label = btn.textContent;
if (!email || email.indexOf('@') < 1) { flash('Enter their email address', false); return; } if (!email || email.indexOf('@') < 1) { flash('Enter their email address', false); return; }
@@ -1036,7 +1043,7 @@ async function sendGuestInvite(ev) {
try { try {
const r = await fetch('/api/guests', { const r = await fetch('/api/guests', {
method: 'POST', headers: {'Content-Type': 'application/json'}, method: 'POST', headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ email }) body: JSON.stringify({ email, name })
}); });
const d = await r.json().catch(() => ({})); const d = await r.json().catch(() => ({}));
if (!r.ok || d.error) { if (!r.ok || d.error) {
@@ -1044,6 +1051,7 @@ async function sendGuestInvite(ev) {
return; return;
} }
$('guest-email').value = ''; $('guest-email').value = '';
$('guest-name').value = '';
flash(d.note || 'Request sent — waiting for approval.', true); flash(d.note || 'Request sent — waiting for approval.', true);
await loadGuests(); await loadGuests();
} catch (e) { } catch (e) {