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
committed by marcel
parent dbf2951f09
commit ed0f3c21fe

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() {
const res = await fetch('/members/invites', { method: 'POST' });
if (res.ok) {
@@ -80,7 +90,7 @@
showInviteCard={isPlanner}
onremove={handleRemove}
onrolechange={handleRoleChange}
oninviteclick={() => (showInvitePanel = !showInvitePanel)}
oninviteclick={handleInviteClick}
/>
{#if showInvitePanel && isPlanner && activeInvite}