diff --git a/components/InviteModal.vue b/components/InviteModal.vue index 743a28b..e43e660 100644 --- a/components/InviteModal.vue +++ b/components/InviteModal.vue @@ -2,8 +2,9 @@
-

{{ invite }}

- +

{{ invite }}

+ +
@@ -36,13 +37,25 @@ async function generateInvite(): Promise { return; } -function copyInvite() { - const inviteUrl = URL.parse(`invite/${invite.value}`, `${window.location.protocol}//${window.location.host}`); - navigator.clipboard.writeText(inviteUrl!.href); +function copyInvite(type: "link" | "code") { + if (!invite.value) return; + + 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); + } } - \ No newline at end of file