Add clipboard functionality and display adventure result
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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
|
||||||
|
};
|
||||||
};
|
};
|
||||||
@@ -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>
|
||||||
Reference in New Issue
Block a user