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;
23 let tippyContent = i18n.t(
24 r.post_report.resolved ? "unresolve_report" : "resolve_report"
27 // Set the original post data ( a troll could change it )
28 post.name = r.post_report.original_post_name;
29 post.url = r.post_report.original_post_url;
30 post.body = r.post_report.original_post_body;
33 creator: r.post_creator,
34 community: r.community,
35 creator_banned_from_community: r.creator_banned_from_community,
40 creator_blocked: false,
49 enableDownvotes={true}
53 {i18n.t("reporter")}: <PersonListing person={r.creator} />
56 {i18n.t("reason")}: {r.post_report.reason}
60 {r.post_report.resolved ? (
61 <T i18nKey="resolved_by">
63 <PersonListing person={r.resolver} />
66 <T i18nKey="unresolved_by">
68 <PersonListing person={r.resolver} />
74 className="btn btn-link btn-animate text-muted py-0"
75 onClick={linkEvent(this, this.handleResolveReport)}
76 data-tippy-content={tippyContent}
77 aria-label={tippyContent}
81 classes={`icon-inline ${
82 r.post_report.resolved ? "text-success" : "text-danger"
90 handleResolveReport(i: PostReport) {
91 let form: ResolvePostReport = {
92 report_id: i.props.report.post_report.id,
93 resolved: !i.props.report.post_report.resolved,
96 WebSocketService.Instance.send(wsClient.resolvePostReport(form));