aboutsummaryrefslogtreecommitdiff
path: root/ui/src/routes/view
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/routes/view')
-rw-r--r--ui/src/routes/view/[id]/+page.svelte24
1 files changed, 20 insertions, 4 deletions
diff --git a/ui/src/routes/view/[id]/+page.svelte b/ui/src/routes/view/[id]/+page.svelte
index 0fc865f..f621dbf 100644
--- a/ui/src/routes/view/[id]/+page.svelte
+++ b/ui/src/routes/view/[id]/+page.svelte
@@ -1,14 +1,13 @@
<script>
- let id = "";
-
+ import { goto } from '$app/navigation';
+
/** @type {import('./$types').PageData} */
export let data;
console.log(data);
- let msg = "";
let copyPromise = null;
let timer = 0;
@@ -20,6 +19,21 @@
return
}, 1000)
}
+
+
+ async function del() {
+ let res = await fetch(`/api/v1/del/${data.id}`, {
+ method: "DELETE",
+ })
+
+ const resp = await res.json()
+ console.log(resp)
+
+ if ('Code' in resp && resp.Code === 200) {
+ goto('/')
+ }
+ }
+
</script>
<h2>ID: {data.id}</h2>
@@ -39,6 +53,8 @@
<button on:click={copy}>Copy to clipboard!</button>
+<button on:click={del}>Delete</button>
+
<pre id="content" class="code">{data.reqJson.Content}</pre>
@@ -60,4 +76,4 @@
}
-</style> \ No newline at end of file
+</style>