diff --git a/src/actions/report.ts b/src/actions/report.ts
index c306efd..f2bd083 100644
--- a/src/actions/report.ts
+++ b/src/actions/report.ts
@@ -117,6 +117,20 @@ export const report = {
};
}
}),
+ editReport: defineAction({
+ input: z.object({
+ reportId: z.number(),
+ reported: z.number().nullable()
+ }),
+ handler: async (input, context) => {
+ Session.actionSessionFromCookies(context.cookies, Permissions.Reports);
+
+ await db.editReport({
+ id: input.reportId,
+ reportedTeamId: input.reported
+ });
+ }
+ }),
reportStatus: defineAction({
input: z.object({
reportId: z.number()
diff --git a/src/app/admin/reports/BottomBar.svelte b/src/app/admin/reports/BottomBar.svelte
index 0d444c3..7addc6d 100644
--- a/src/app/admin/reports/BottomBar.svelte
+++ b/src/app/admin/reports/BottomBar.svelte
@@ -1,5 +1,5 @@
@@ -64,7 +70,7 @@
-
+ (reportedTeam = team)} />
diff --git a/src/app/admin/reports/reports.ts b/src/app/admin/reports/reports.ts
index 110f6c8..6f5e19d 100644
--- a/src/app/admin/reports/reports.ts
+++ b/src/app/admin/reports/reports.ts
@@ -59,6 +59,17 @@ export async function getReportStatus(report: Report) {
return data.reportStatus;
}
+export async function editReport(report: Report) {
+ const { error } = await actions.report.editReport({
+ reportId: report.id,
+ reported: report.reported?.id ?? null
+ });
+
+ if (error) {
+ actionErrorPopup(error);
+ }
+}
+
export async function editReportStatus(report: Report, reportStatus: ReportStatus) {
const { error } = await actions.report.editReportStatus({
reportId: report.id,
diff --git a/src/app/website/index/Teams.svelte b/src/app/website/index/Teams.svelte
index 53b146c..6d2d78c 100644
--- a/src/app/website/index/Teams.svelte
+++ b/src/app/website/index/Teams.svelte
@@ -48,10 +48,7 @@
-
+
addReport(this.db, values);
+ editReport = (values: EditReportReq) => editReport(this.db, values);
submitReport = (values: SubmitReportReq) => submitReport(this.db, values);
getReports = (values: GetReportsReq) => getReports(this.db, values);
getReportById = (values: GetReportById) => getReportById(this.db, values);
diff --git a/src/db/schema/report.ts b/src/db/schema/report.ts
index 8f4ea4f..3ec00dc 100644
--- a/src/db/schema/report.ts
+++ b/src/db/schema/report.ts
@@ -28,6 +28,11 @@ export type AddReportReq = {
reportedTeamId?: number | null;
};
+export type EditReportReq = {
+ id: number;
+ reportedTeamId: number | null;
+};
+
export type SubmitReportReq = {
urlHash: string;
reason: string;
@@ -65,6 +70,12 @@ export async function addReport(db: Database, values: AddReportReq) {
return Object.assign(r[0], { url: `${BASE_PATH}/report/${urlHash}` });
}
+export async function editReport(db: Database, values: EditReportReq) {
+ return db.update(report).set({
+ reportedTeamId: values.reportedTeamId
+ });
+}
+
export async function submitReport(db: Database, values: SubmitReportReq) {
return db
.update(report)
diff --git a/src/util/webhook.ts b/src/util/webhook.ts
index 0e97fe6..c5132a0 100644
--- a/src/util/webhook.ts
+++ b/src/util/webhook.ts
@@ -23,7 +23,7 @@ export async function sendWebhook(action: T, data: Webh
'Content-Type': 'application/json',
'x-webhook-action': action
},
- body: JSON.stringify(data),
+ body: JSON.stringify(data)
});
if (response.status === 200) return;
|