diff --git a/map4.js b/map4.js index 957d2c9..876ff49 100644 --- a/map4.js +++ b/map4.js @@ -57,6 +57,20 @@ .select("password") .eq("group_name", groupName) .maybeSingle(); +if (inviteBtn) { + inviteBtn.addEventListener("click", async () => { + + if (!currentGroup) { + alert("グループ情報が取得できません。"); + return; + } + + // Supabase からパスワード取得 + const { data, error } = await supa + .from("groups") + .select("password") + .eq("group_name", currentGroup) + .maybeSingle(); if (!data || error) { alert("グループ情報が取得できませんでした"); @@ -65,10 +79,19 @@ const pass = data.password; - // join_group.html に誘導する招待URL + // join_group.html への招待リンク const inviteURL = - `https://www.yatex.org/gitbucket/KoekiGameDesign/2025-shino/pages/join_group.html` - + `?group=${encodeURIComponent(groupName)}&pass=${encodeURIComponent(pass)}`; + `https://www.yatex.org/gitbucket/KoekiGameDesign/2025-shino/pages/join_group.html` + + `?group=${encodeURIComponent(currentGroup)}&pass=${encodeURIComponent(pass)}`; + + try { + await navigator.clipboard.writeText(inviteURL); + alert("🎉 招待リンクをコピーしました!"); + } catch (e) { + alert("コピーに失敗しました…"); + } + }); +} try { await navigator.clipboard.writeText(inviteURL);