make report body actually editable on user report page
This commit is contained in:
parent
722026c938
commit
61ea07d371
@ -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 });
|
||||
|
@ -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 @@
|
||||
<form on:submit|preventDefault={() => submitModal.show()}>
|
||||
<div class="space-y-4 my-4">
|
||||
<div>
|
||||
<Input type="text" value={reason} required={true} pickyWidth={false}>
|
||||
<Input type="text" bind:value={reason} required={true} pickyWidth={false}>
|
||||
<span slot="label">Report Grund</span>
|
||||
</Input>
|
||||
</div>
|
||||
<div>
|
||||
<Textarea required={true} rows={4} label="Details über den Report Grund" />
|
||||
<Textarea
|
||||
required={true}
|
||||
rows={4}
|
||||
label="Details über den Report Grund"
|
||||
bind:value={body}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user