From c87b5c53077c02bf21234e24bf976aa7a5f2bac8 Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Fri, 25 Oct 2024 02:09:25 -0400
Subject: Take a swing at putting an invite UI in place.

---
 ui/lib/components/Invite.svelte | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 ui/lib/components/Invite.svelte

(limited to 'ui/lib/components/Invite.svelte')

diff --git a/ui/lib/components/Invite.svelte b/ui/lib/components/Invite.svelte
new file mode 100644
index 0000000..f4babad
--- /dev/null
+++ b/ui/lib/components/Invite.svelte
@@ -0,0 +1,40 @@
+<script>
+	import { base } from '$app/paths';
+	import { createInvite } from '$lib/apiServer';
+	import { clipboard } from '@skeletonlabs/skeleton';
+
+	let invite = null;
+	$: inviteUrl = invite ? new URL(`/invite/${invite.id}`, document.location) : null;
+	$: inviteUrl, console.log("invite url", inviteUrl);
+
+	async function onSubmit() {
+		let response = await createInvite();
+		if (response.status == 200) {
+			invite = response.data;
+		}
+		console.log("base url", base);
+	}
+
+	async function onReset() {
+		invite = null;
+	}
+</script>
+
+<form
+	on:submit|preventDefault={onSubmit}
+	on:reset|preventDefault={onReset}>
+	{#if inviteUrl}
+	<button
+		class="border-slate-500 border-solid border-2 font-bold p-1 rounded"
+		use:clipboard={inviteUrl}
+		type="reset">
+		Copy Invite
+	</button>
+	{:else}
+	<button
+		class="border-slate-500 border-solid border-2 font-bold p-1 rounded"
+		type="submit">
+		Invite
+	</button>
+	{/if}
+</form>
-- 
cgit v1.2.3

