aboutsummaryrefslogtreecommitdiff
path: root/ui/src/routes/new
diff options
context:
space:
mode:
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>