Add invite link to Admin panel
The Admin panel now shows the crew's join link (origin/#/game/{id}/join)
with Open and Copy buttons, so an admin can invite new players without
returning to the lobby. Matches the existing rejoin-link copy pattern.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,11 +10,17 @@
|
||||
let error = '';
|
||||
let copiedPlayerId = null;
|
||||
let copiedTimer = null;
|
||||
let copiedInvite = false;
|
||||
let copiedInviteTimer = null;
|
||||
|
||||
function rejoinLink(playerId) {
|
||||
return `${window.location.origin}/#/game/${gameId}/player/${playerId}`;
|
||||
}
|
||||
|
||||
function inviteLink() {
|
||||
return `${window.location.origin}/#/game/${gameId}/join`;
|
||||
}
|
||||
|
||||
function copyRejoinLink(playerId) {
|
||||
navigator.clipboard.writeText(rejoinLink(playerId));
|
||||
copiedPlayerId = playerId;
|
||||
@@ -22,6 +28,13 @@
|
||||
copiedTimer = setTimeout(() => { copiedPlayerId = null; }, 2000);
|
||||
}
|
||||
|
||||
function copyInviteLink() {
|
||||
navigator.clipboard.writeText(inviteLink());
|
||||
copiedInvite = true;
|
||||
clearTimeout(copiedInviteTimer);
|
||||
copiedInviteTimer = setTimeout(() => { copiedInvite = false; }, 2000);
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
// Try to load admin_key from local storage
|
||||
adminKey = localStorage.getItem(`admin_key_${gameId}`) || '';
|
||||
@@ -75,6 +88,16 @@
|
||||
<p><strong>Phase:</strong> {data.game.phase}</p>
|
||||
<p><strong>Admin Key:</strong> <span class="admin-key-chip">{data.game.admin_key}</span></p>
|
||||
|
||||
<h3 class="mt-8 mb-4">Invite Link</h3>
|
||||
<p class="info-text">Share this link to let new players join the crew.</p>
|
||||
<div class="link-copy-action">
|
||||
<input type="text" readonly value={inviteLink()} class="input-field flex-grow" />
|
||||
<a href={inviteLink()} class="btn btn-secondary btn-small">Open</a>
|
||||
<button on:click={copyInviteLink} class="btn btn-secondary btn-small">
|
||||
{copiedInvite ? '✓ Copied' : 'Copy'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h3 class="mt-8 mb-4">Players</h3>
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user