feat: add invite popup component
This commit is contained in:
parent
646ae78776
commit
8ce2d52044
1 changed files with 40 additions and 0 deletions
40
components/InvitePopup.vue
Normal file
40
components/InvitePopup.vue
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<template>
|
||||||
|
<div id="invite-popup">
|
||||||
|
<div v-if="invite">
|
||||||
|
<p>{{ invite }}</p>
|
||||||
|
<button @click="copyInvite">Copy Link</button>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<button @click="generateInvite">Generate Invite</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { InviteResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
|
|
||||||
|
const invite = ref<string>();
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
async function generateInvite(): Promise<void> {
|
||||||
|
const createdInvite: InviteResponse | undefined = await fetchWithApi(
|
||||||
|
`/servers/${route.params.serverId}/invites`,
|
||||||
|
{ method: "POST", body: { custom_id: "oijewfoiewf" } }
|
||||||
|
);
|
||||||
|
|
||||||
|
invite.value = createdInvite?.id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyInvite() {
|
||||||
|
const inviteUrl = URL.parse(`invite/${invite.value}`, `${window.location.protocol}//${window.location.host}`);
|
||||||
|
navigator.clipboard.writeText(inviteUrl!.href);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
Loading…
Add table
Add a link
Reference in a new issue