From 6c205a0ad39f37b77c0be879b6746af4743a9260 Mon Sep 17 00:00:00 2001 From: Xodrium <118943715+malloc62@users.noreply.github.com> Date: Sat, 11 Feb 2023 02:11:45 -0500 Subject: [PATCH] Added post deletion --- src/lib/components/Image.svelte | 0 src/lib/components/Post.svelte | 28 ++++++++++++++-- src/lib/db/db.js | 22 +++++++++++-- src/routes/post/[post]/+page.js | 2 +- src/routes/post/[post]/+page.svelte | 14 ++++---- src/routes/user/[user]/+page.svelte | 15 +++++---- static/delete.svg | 50 +++++++++++++++++++++++++++++ 7 files changed, 110 insertions(+), 21 deletions(-) create mode 100644 src/lib/components/Image.svelte create mode 100644 static/delete.svg diff --git a/src/lib/components/Image.svelte b/src/lib/components/Image.svelte new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/components/Post.svelte b/src/lib/components/Post.svelte index 5952384..cad9002 100644 --- a/src/lib/components/Post.svelte +++ b/src/lib/components/Post.svelte @@ -3,7 +3,7 @@ import PostButton from '$lib/components/PostButton.svelte'; import PostBody from '$lib/components/PostBody.svelte'; - export let success, username, content, upvotes, downvotes, id; + export let success, username, content, upvotes, downvotes, id, isAuthor; let query = (id) ? `/post/${id}` : ''; @@ -24,6 +24,20 @@ downvotes = j.data.down; }) } + + function deletePost(v) { + fData = (new FormData()); + + fData.append('id',id); + + fetch('/api/postDelete', { + method: 'POST', + body: fData + }).then(async x => { + window.location.href = '/'; + }) + } +