From f02e64fca7f14c143b1d71a427f041f26400164d Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 23 Mar 2023 15:20:07 +0100 Subject: [PATCH] feat: add report button to profiles --- backend/db/report.go | 2 +- frontend/src/routes/@[username]/+page.svelte | 6 ++ .../routes/@[username]/ReportButton.svelte | 60 +++++++++++++++++++ .../@[username]/[memberName]/+page.svelte | 6 ++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 frontend/src/routes/@[username]/ReportButton.svelte diff --git a/backend/db/report.go b/backend/db/report.go index 70e2614..c2bfe48 100644 --- a/backend/db/report.go +++ b/backend/db/report.go @@ -14,7 +14,7 @@ type Report struct { ID int64 `json:"id"` UserID xid.ID `json:"user_id"` UserName string `json:"user_name"` - MemberID *xid.ID `json:"member_id"` + MemberID xid.ID `json:"member_id"` MemberName *string `json:"member_name"` Reason string `json:"reason"` ReporterID xid.ID `json:"reporter_id"` diff --git a/frontend/src/routes/@[username]/+page.svelte b/frontend/src/routes/@[username]/+page.svelte index d249579..18f8513 100644 --- a/frontend/src/routes/@[username]/+page.svelte +++ b/frontend/src/routes/@[username]/+page.svelte @@ -31,6 +31,7 @@ import ErrorAlert from "$lib/components/ErrorAlert.svelte"; import { goto } from "$app/navigation"; import renderMarkdown from "$lib/api/markdown"; + import ReportButton from "./ReportButton.svelte"; export let data: PageData; @@ -149,6 +150,11 @@ {/each} + {#if $userStore && $userStore.id !== data.id} +
+ +
+ {/if} {#if data.members.length > 0 || ($userStore && $userStore.id === data.id)}
diff --git a/frontend/src/routes/@[username]/ReportButton.svelte b/frontend/src/routes/@[username]/ReportButton.svelte new file mode 100644 index 0000000..cd63685 --- /dev/null +++ b/frontend/src/routes/@[username]/ReportButton.svelte @@ -0,0 +1,60 @@ + + +
+ +
+ + + + {#if error} + + {/if} + +