diff --git a/src/routes/report/[...url_hash]/+server.ts b/src/routes/report/[...url_hash]/+server.ts index 02cb0d9..963031b 100644 --- a/src/routes/report/[...url_hash]/+server.ts +++ b/src/routes/report/[...url_hash]/+server.ts @@ -1,12 +1,15 @@ import type { RequestHandler } from '@sveltejs/kit'; import { Report } from '$lib/server/database'; -export const POST = (async ({ params }) => { +export const POST = (async ({ request, params }) => { const report = await Report.findOne({ where: { url_hash: params.url_hash } }); if (report == null) return new Response(null, { status: 400 }); + const data: { body: string } = await request.json(); + report.draft = false; + report.body = data.body || ''; await report.save(); return new Response(null, { status: 200 }); diff --git a/src/routes/report/[...url_hash]/ReportDraft.svelte b/src/routes/report/[...url_hash]/ReportDraft.svelte index 9bfdd3f..ed7bb63 100644 --- a/src/routes/report/[...url_hash]/ReportDraft.svelte +++ b/src/routes/report/[...url_hash]/ReportDraft.svelte @@ -8,9 +8,14 @@ export let reportedName: string; export let reason: string; + let body: string; + async function submitReport() { await fetch(`${env.PUBLIC_BASE_PATH}/report/${$page.params.url_hash}`, { - method: 'POST' + method: 'POST', + body: JSON.stringify({ + body: body + }) }); } @@ -24,12 +29,17 @@
submitModal.show()}>
- + Report Grund
-