1 import { Component, linkEvent } from "inferno";
2 import { T } from "inferno-i18next-dess";
3 import { PostReportView, PostView, ResolvePostReport } from "lemmy-js-client";
4 import { i18n } from "../../i18next";
5 import { WebSocketService } from "../../services";
6 import { authField, wsClient } from "../../utils";
7 import { Icon } from "../common/icon";
8 import { PersonListing } from "../person/person-listing";
9 import { PostListing } from "./post-listing";
11 interface PostReportProps {
12 report: PostReportView;
15 export class PostReport extends Component<PostReportProps, any> {
16 constructor(props: any, context: any) {
17 super(props, context);
21 let r = this.props.report;
24 // Set the original post data ( a troll could change it )
25 post.name = r.post_report.original_post_name;
26 post.url = r.post_report.original_post_url;
27 post.body = r.post_report.original_post_body;
30 creator: r.post_creator,
31 community: r.community,
32 creator_banned_from_community: r.creator_banned_from_community,
37 creator_blocked: false,
46 enableDownvotes={true}
50 {i18n.t("reporter")}: <PersonListing person={r.creator} />
53 {i18n.t("reason")}: {r.post_report.reason}
57 {r.post_report.resolved ? (
58 <T i18nKey="resolved_by">
60 <PersonListing person={r.resolver} />
63 <T i18nKey="unresolved_by">
65 <PersonListing person={r.resolver} />
71 className="btn btn-link btn-animate text-muted py-0"
72 onClick={linkEvent(this, this.handleResolveReport)}
74 r.post_report.resolved ? "unresolve_report" : "resolve_report"
77 r.post_report.resolved ? "unresolve_report" : "resolve_report"
82 classes={`icon-inline ${
83 r.post_report.resolved ? "text-success" : "text-danger"
91 handleResolveReport(i: PostReport) {
92 let form: ResolvePostReport = {
93 report_id: i.props.report.post_report.id,
94 resolved: !i.props.report.post_report.resolved,
97 WebSocketService.Instance.send(wsClient.resolvePostReport(form));