fix: improved email send feedback (prominent success banner, loading state)

This commit is contained in:
gitadmin 2026-05-02 14:40:53 +00:00
parent e63c6be521
commit 0dd15d3541

View file

@ -3200,7 +3200,7 @@ h1{font-size:1.6rem;color:#f0e8d0;margin-bottom:4px}
<p style="font-size:.82rem;color:#6b7f99;margin-bottom:14px">Are you the steward or a collaborator for this agent? Enter your email to receive a secure link to your corpus portal.</p>
<div style="display:flex;gap:8px;flex-wrap:wrap;align-items:center">
<input type="email" id="steward-email" placeholder="your@email.com" style="flex:1;min-width:200px;background:#060e1c;border:1px solid #1a2e44;border-radius:5px;padding:8px 10px;color:#d4cfbb;font-family:inherit;font-size:.82rem;box-sizing:border-box">
<button onclick="requestPortfolioAccess()" style="padding:8px 16px;background:#1a2e4a;color:#c9b87e;border:1px solid #c9b87e44;border-radius:5px;font-size:.82rem;font-weight:600;cursor:pointer;font-family:inherit;white-space:nowrap">Send my link </button>
<button id="steward-access-btn" onclick="requestPortfolioAccess()" style="padding:8px 16px;background:#1a2e4a;color:#c9b87e;border:1px solid #c9b87e44;border-radius:5px;font-size:.82rem;font-weight:600;cursor:pointer;font-family:inherit;white-space:nowrap">Send my link </button>
</div>
<div id="steward-access-result" style="margin-top:8px;font-size:.8rem;color:#6b7f99"></div>
</div>
@ -3232,9 +3232,16 @@ document.getElementById('q')?.addEventListener('keydown', e => { if (e.key === '
async function requestPortfolioAccess() {
const emailEl = document.getElementById('steward-email');
const result = document.getElementById('steward-access-result');
const btn = document.getElementById('steward-access-btn');
const email = emailEl.value.trim();
if (!email || !email.includes('@')) { result.textContent = 'Please enter a valid email address.'; result.style.color = '#f87171'; return; }
result.textContent = 'Sending…'; result.style.color = '#6b7f99';
if (!email || !email.includes('@')) {
result.style.cssText = 'margin-top:10px;font-size:.85rem;color:#f87171;font-weight:500';
result.textContent = 'Please enter a valid email address.';
return;
}
result.style.cssText = 'margin-top:8px;font-size:.82rem;color:#6b7f99';
result.textContent = 'Sending…';
if (btn) { btn.disabled = true; btn.textContent = 'Sending…'; }
try {
const r = await fetch('/api/agentify-help/portfolio-access', {
method: 'POST', headers: { 'Content-Type': 'application/json' },
@ -3242,15 +3249,19 @@ async function requestPortfolioAccess() {
});
const d = await r.json();
if (d.ok && d.sent !== false) {
result.textContent = '✓ Check your inbox — your steward link is on the way.';
result.style.color = '#22c55e';
result.style.cssText = 'margin-top:12px;font-size:.88rem;color:#22c55e;font-weight:600;padding:10px 14px;background:rgba(34,197,94,0.08);border:1px solid rgba(34,197,94,0.25);border-radius:6px;display:block';
result.textContent = '✓ Link sent! Check your inbox — and your spam folder if you don\'t see it within a minute.';
if (btn) { btn.disabled = true; btn.textContent = 'Sent ✓'; btn.style.opacity = '0.6'; }
emailEl.value = '';
} else {
result.style.cssText = 'margin-top:10px;font-size:.85rem;color:#f87171;font-weight:500';
result.textContent = d.message || 'No steward account found for that email.';
result.style.color = '#f87171';
if (btn) { btn.disabled = false; btn.textContent = 'Send my link →'; }
}
} catch(e) {
result.textContent = 'Error sending link. Please try again.';
result.style.color = '#f87171';
result.style.cssText = 'margin-top:10px;font-size:.85rem;color:#f87171;font-weight:500';
result.textContent = 'Network error — please try again.';
if (btn) { btn.disabled = false; btn.textContent = 'Send my link →'; }
}
}