fix(members): create invite on first click when no active invite exists

When activeInvite is null and the user clicks the invite card, POST to
/members/invites first to generate a code, then toggle the panel open.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 19:55:00 +02:00
parent 4e67ff4258
commit c40b0fe095

View File

@@ -59,6 +59,16 @@
} }
} }
async function handleInviteClick() {
if (!activeInvite) {
const res = await fetch('/members/invites', { method: 'POST' });
if (res.ok) {
activeInvite = await res.json();
}
}
showInvitePanel = !showInvitePanel;
}
async function handleRegenerate() { async function handleRegenerate() {
const res = await fetch('/members/invites', { method: 'POST' }); const res = await fetch('/members/invites', { method: 'POST' });
if (res.ok) { if (res.ok) {
@@ -80,7 +90,7 @@
showInviteCard={isPlanner} showInviteCard={isPlanner}
onremove={handleRemove} onremove={handleRemove}
onrolechange={handleRoleChange} onrolechange={handleRoleChange}
oninviteclick={() => (showInvitePanel = !showInvitePanel)} oninviteclick={handleInviteClick}
/> />
{#if showInvitePanel && isPlanner && activeInvite} {#if showInvitePanel && isPlanner && activeInvite}