From 0280e2a277557340ff25962ed892f0dfabdd74c4 Mon Sep 17 00:00:00 2001 From: bytedream <bytedream@protonmail.com> Date: Fri, 20 Dec 2024 19:24:59 +0100 Subject: [PATCH] fix report details not showing after report is submitted --- src/routes/report/[...url_hash]/+page.svelte | 19 ++++++++++++------- .../report/[...url_hash]/ReportDraft.svelte | 13 +++++++------ .../[...url_hash]/ReportSubmitted.svelte | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/routes/report/[...url_hash]/+page.svelte b/src/routes/report/[...url_hash]/+page.svelte index be71df6..1596927 100644 --- a/src/routes/report/[...url_hash]/+page.svelte +++ b/src/routes/report/[...url_hash]/+page.svelte @@ -5,6 +5,10 @@ let { data } = $props(); + let reason = $state(data.reason); + let body = $state(data.body); + let reporterName = $state(data.reporter.name); + let reportedName = $state(data.reported.name || null); let completed = $state(!data.draft); </script> @@ -18,9 +22,10 @@ {#if !completed} <div class="col-[1] row-[1]" transition:fly={{ x: -200, duration: 300 }}> <ReportDraft - reason={data.reason} - reporterName={data.reporter.name} - reportedName={data.reported.name ?? null} + bind:reason + bind:body + bind:reporterName + bind:reportedName users={data.users ?? []} onsubmit={() => (completed = true)} /> @@ -28,11 +33,11 @@ {:else} <div class="col-[1] row-[1]" transition:fly={{ x: 200, duration: 300 }}> <ReportSubmitted - reporterName={data.reporter.name} - reportedName={data.reported.name ?? undefined} + {reason} + {body} + {reporterName} + {reportedName} status={data.status} - reason={data.reason} - body={data.body} statement={data.statement} /> </div> diff --git a/src/routes/report/[...url_hash]/ReportDraft.svelte b/src/routes/report/[...url_hash]/ReportDraft.svelte index 746b310..b8baa99 100644 --- a/src/routes/report/[...url_hash]/ReportDraft.svelte +++ b/src/routes/report/[...url_hash]/ReportDraft.svelte @@ -8,15 +8,17 @@ import { getPopupModalShowFn } from '$lib/context'; let { - reporterName, - reportedName = null, - reason, + reporterName = $bindable(), + reportedName = $bindable(null), + reason = $bindable(), + body = $bindable(), users, onsubmit }: { reporterName: string; reportedName: string | null; reason: string; + body: string; users: string[]; onsubmit: () => void; } = $props(); @@ -24,7 +26,6 @@ let showPopupModal = getPopupModalShowFn(); let reported = $state(reportedName); - let content = $state(''); async function submitReport() { await fetch(`${env.PUBLIC_BASE_PATH}/report/${$page.params.url_hash}`, { @@ -32,7 +33,7 @@ body: JSON.stringify({ reported: reported || null, subject: reason, - body: content + body: body }) }); } @@ -108,7 +109,7 @@ required={true} rows={4} label="Details über den Report Grund" - bind:value={content} + bind:value={body} /> </div> </div> diff --git a/src/routes/report/[...url_hash]/ReportSubmitted.svelte b/src/routes/report/[...url_hash]/ReportSubmitted.svelte index 400f5e5..5fa7d83 100644 --- a/src/routes/report/[...url_hash]/ReportSubmitted.svelte +++ b/src/routes/report/[...url_hash]/ReportSubmitted.svelte @@ -11,7 +11,7 @@ statement }: { reporterName: string; - reportedName?: string; + reportedName: string | null; status: 'none' | 'review' | 'reviewed'; reason: string; body: string;