feat: add buttons for copying invite in link and plain code forms
This commit is contained in:
parent
6578b95704
commit
1dfb964dd2
1 changed files with 19 additions and 6 deletions
|
@ -2,8 +2,9 @@
|
||||||
<Modal v-bind="props" :title="props.title || 'Create an invite'">
|
<Modal v-bind="props" :title="props.title || 'Create an invite'">
|
||||||
<div id="invite-popup">
|
<div id="invite-popup">
|
||||||
<div v-if="invite">
|
<div v-if="invite">
|
||||||
<p>{{ invite }}</p>
|
<p id="invite-label">{{ invite }}</p>
|
||||||
<button @click="copyInvite">Copy Link</button>
|
<button @click="copyInvite('link')">Copy Link</button>
|
||||||
|
<button @click="copyInvite('code')">Copy Code</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<button @click="generateInvite">Generate Invite</button>
|
<button @click="generateInvite">Generate Invite</button>
|
||||||
|
@ -36,13 +37,25 @@ async function generateInvite(): Promise<void> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyInvite() {
|
function copyInvite(type: "link" | "code") {
|
||||||
const inviteUrl = URL.parse(`invite/${invite.value}`, `${window.location.protocol}//${window.location.host}`);
|
if (!invite.value) return;
|
||||||
navigator.clipboard.writeText(inviteUrl!.href);
|
|
||||||
|
if (type == "link") {
|
||||||
|
const inviteUrl = URL.parse(`invite/${invite.value}`, `${window.location.protocol}//${window.location.host}`);
|
||||||
|
if (inviteUrl) {
|
||||||
|
navigator.clipboard.writeText(inviteUrl.href);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
navigator.clipboard.writeText(invite.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped>
|
||||||
|
|
||||||
|
#invite-label {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
Loading…
Add table
Add a link
Reference in a new issue