/* GoToSocial Copyright (C) GoToSocial Authors admin@gotosocial.org SPDX-License-Identifier: AGPL-3.0-or-later This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ import React from "react"; import { useLocation, useParams } from "wouter"; import FormWithData from "../../../lib/form/form-with-data"; import BackButton from "../../../components/back-button"; import { useValue, useTextInput } from "../../../lib/form"; import useFormSubmit from "../../../lib/form/submit"; import { TextArea } from "../../../components/form/inputs"; import MutationButton from "../../../components/form/mutation-button"; import UsernameLozenge from "../../../components/username-lozenge"; import { useGetReportQuery, useResolveReportMutation } from "../../../lib/query/admin/reports"; import { useBaseUrl } from "../../../lib/navigation/util"; import { AdminReport } from "../../../lib/types/report"; import { yesOrNo } from "../../../lib/util"; import { Status } from "../../../components/status"; export default function ReportDetail({ }) { const params: { reportId: string } = useParams(); const baseUrl = useBaseUrl(); const backLocation: String = history.state?.backLocation ?? `~${baseUrl}`; return (

Report Details

); } function ReportDetailForm({ data: report }: { data: AdminReport }) { const [ location ] = useLocation(); const baseUrl = useBaseUrl(); return ( <> { report.action_taken && } { report.statuses && } { !report.action_taken && } ); } interface ReportSectionProps { report: AdminReport; baseUrl: string; location: string; } function ReportBasicInfo({ report, baseUrl, location }: ReportSectionProps) { const from = report.account; const target = report.target_account; const comment = report.comment; const status = report.action_taken ? "Resolved" : "Unresolved"; const created = new Date(report.created_at).toLocaleString(); return (
Reported account
Reported by
Status
{ report.action_taken ? <>{status} : {status} }
Reason
{ comment.length > 0 ? <>{comment} : none provided }
Created
Category
{ report.category }
Forwarded
{ yesOrNo(report.forwarded) }
); } function ReportHistory({ report, baseUrl, location }: ReportSectionProps) { const handled_by = report.action_taken_by_account; if (!handled_by) { throw "report handled by action_taken_by_account undefined"; } const handled = report.action_taken_at ? new Date(report.action_taken_at).toLocaleString() : "never"; return ( <>

Moderation History

Handled by
Handled
Comment
{ report.action_taken_comment ?? "none"}
); } function ReportActionForm({ report }) { const form = { id: useValue("id", report.id), comment: useTextInput("action_taken_comment") }; const [submit, result] = useFormSubmit(form, useResolveReportMutation(), { changedOnly: false }); return (

Resolve this report

<> An optional comment can be included while resolving this report. This is useful for providing an explanation about what action was taken (if any) before the report was marked as resolved.
If the report was created by a local account, then any comment made here will be emailed to that account's user!