1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-28 09:19:37 +02:00

Add clipboard functionality and display adventure result

This commit is contained in:
Sean Morley 2024-04-02 19:21:10 +00:00
parent 0dde2fbe6a
commit d86eaeb0be
3 changed files with 16 additions and 1 deletions

View file

@ -93,6 +93,8 @@
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log('Success:', data); console.log('Success:', data);
let url = window.location.origin + '/shared/' + key
navigator.clipboard.writeText(url)
}) })
.catch((error) => { .catch((error) => {
console.error('Error:', error); console.error('Error:', error);

View file

@ -1,9 +1,14 @@
import { db } from "$lib/db/db.server"; import { db } from "$lib/db/db.server";
import { sharedAdventures } from "$lib/db/schema"; import { sharedAdventures } from "$lib/db/schema";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import type { Adventure } from "$lib/utils/types";
export async function load({ params }) { export async function load({ params }) {
let key = params.key; let key = params.key;
let result = await db.select().from(sharedAdventures).where(eq(sharedAdventures.id, key)).execute(); let result = await db.select().from(sharedAdventures).where(eq(sharedAdventures.id, key)).execute();
console.log(result); let adventure = result[0].data as Adventure;
console.log(adventure);
return {
result: adventure
};
}; };

View file

@ -0,0 +1,8 @@
<script lang="ts">
import type { Adventure } from '$lib/utils/types'
export let data;
let result = data.result;
</script>
<p>{result}</p>