Standard guest-invite form: one email field, no name input
Same form as the admin panel: 'Invite a guest' heading, a single required email input, a 'Send invite' button, submit on Enter. The inviter is the logged-in member (automatic); the portal applies the one-per-30-days rule, recipient checks and the pending-approval gate as before. No name is collected or derived — the guest chooses their own at Cloudron setup.
This commit is contained in:
1 parent
84d5389eb6
commit
8f8106742a
1 file changed
+16
-10
+16
-10
@@ -630,7 +630,9 @@ PAGE_HTML = """<!DOCTYPE html>
|
||||
|
||||
/* ---------- Guest access (members inviting a friend) ---------- */
|
||||
.guest-hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
|
||||
.new-key .name-input { max-width: 200px; }
|
||||
/* Standard guest-invite form (shared with the admin panel): ONE field. */
|
||||
.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; }
|
||||
.guest-trail { margin-top: 6px; }
|
||||
.guest-row {
|
||||
display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
|
||||
@@ -843,11 +845,12 @@ PAGE_HTML = """<!DOCTYPE html>
|
||||
<div class="card" id="guests-card" style="display:none">
|
||||
<h2>Guest access</h2>
|
||||
<p class="guest-hint" id="guest-hint">Give a friend $5 of AI credits for the co-op's chat and API — no membership needed. They get 60 days to try it. One guest per member every 30 days.</p>
|
||||
<div class="new-key">
|
||||
<input id="guest-email" type="email" placeholder="their@email.org" maxlength="254" />
|
||||
<input id="guest-name" type="text" class="name-input" placeholder="Their name (optional)" maxlength="80" />
|
||||
<button class="primary" id="guest-btn" onclick="sendGuestInvite()">Send request</button>
|
||||
</div>
|
||||
<h3 class="guest-invite-title">Invite a guest</h3>
|
||||
<form class="new-key" id="guest-invite-form" onsubmit="sendGuestInvite(event)">
|
||||
<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" />
|
||||
<button class="primary" id="guest-btn" type="submit">Send invite</button>
|
||||
</form>
|
||||
<div class="hint" id="guest-allowance"></div>
|
||||
<div class="guest-trail" id="guest-trail"></div>
|
||||
</div>
|
||||
@@ -1018,9 +1021,13 @@ function renderGuests(d) {
|
||||
}).join('');
|
||||
}
|
||||
|
||||
async function sendGuestInvite() {
|
||||
// The standard guest-invite form (ONE field: the guest's email). The inviter
|
||||
// is the logged-in member — automatic, no field; the portal applies the
|
||||
// member-side protections (active member, one per 30 days, recipient checks)
|
||||
// and, with the trial gate on, holds the request for approval.
|
||||
async function sendGuestInvite(ev) {
|
||||
if (ev) ev.preventDefault();
|
||||
const email = ($('guest-email').value || '').trim();
|
||||
const name = ($('guest-name').value || '').trim();
|
||||
const btn = $('guest-btn');
|
||||
const label = btn.textContent;
|
||||
if (!email || email.indexOf('@') < 1) { flash('Enter their email address', false); return; }
|
||||
@@ -1029,7 +1036,7 @@ async function sendGuestInvite() {
|
||||
try {
|
||||
const r = await fetch('/api/guests', {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({ email, name })
|
||||
body: JSON.stringify({ email })
|
||||
});
|
||||
const d = await r.json().catch(() => ({}));
|
||||
if (!r.ok || d.error) {
|
||||
@@ -1037,7 +1044,6 @@ async function sendGuestInvite() {
|
||||
return;
|
||||
}
|
||||
$('guest-email').value = '';
|
||||
$('guest-name').value = '';
|
||||
flash(d.note || 'Request sent — waiting for approval.', true);
|
||||
await loadGuests();
|
||||
} catch (e) {
|
||||
|
||||
Reference in new issue
Block a user