aboutsummaryrefslogtreecommitdiff
path: root/ui/src/routes/new
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2023-01-03 19:29:58 -0500
committerMitchell Riedstra <mitch@riedstra.dev>2023-01-03 19:29:58 -0500
commit5ee149d5279408c0a0ee3e7e91e88241b2fb17ff (patch)
treef0120f1a55039c3ec08b6524c505632174cf7674 /ui/src/routes/new
parent7c01e12341f79a7bdf085a141e303d209fd8b3c5 (diff)
downloadpaste-5ee149d5279408c0a0ee3e7e91e88241b2fb17ff.tar.gz
paste-5ee149d5279408c0a0ee3e7e91e88241b2fb17ff.tar.xz
Creating new pastes from the UI works. As does the login page.
Still need to redirect to login page automatically. Also need to show only one of Logout or Login at a time.
Diffstat (limited to 'ui/src/routes/new')
-rw-r--r--ui/src/routes/new/+page.svelte28
1 files changed, 25 insertions, 3 deletions
diff --git a/ui/src/routes/new/+page.svelte b/ui/src/routes/new/+page.svelte
index 28687e4..10557af 100644
--- a/ui/src/routes/new/+page.svelte
+++ b/ui/src/routes/new/+page.svelte
@@ -1,5 +1,27 @@
+<script>
+ import { goto } from '$app/navigation';
+ let content = '';
+ // $: console.log("Content is: ", content)
+ async function save() {
+ const res = await fetch("/api/v1/new", {
+ method: 'POST',
+ body: JSON.stringify({
+ content: content,
+ })
+ })
+
+ const resp = await res.json()
+ console.log(resp)
+
+ if ('Code' in resp && resp.Code === 200) {
+ goto('view/' + resp.Data.Id)
+ }
+
+ }
+
+</script>
<div class="content">
@@ -9,11 +31,11 @@
<label for="content">Content:</label>
<br />
<br />
-<textarea name="content" id="content" cols="80" rows="20"></textarea>
+<textarea name="content" id="content" cols="80" rows="20" bind:value={content}></textarea>
<br />
<br />
-<button type="submit">Save</button>
+<button type="submit" on:click={save}>Save</button>
</div>
@@ -41,4 +63,4 @@ textarea {
}
-</style> \ No newline at end of file
+</style>