1 import { Component, linkEvent } from "inferno";
2 import { T } from "inferno-i18next-dess";
8 } from "lemmy-js-client";
9 import { i18n } from "../../i18next";
10 import { WebSocketService } from "../../services";
11 import { myAuth, wsClient } from "../../utils";
12 import { Icon } from "../common/icon";
13 import { PersonListing } from "../person/person-listing";
14 import { PostListing } from "./post-listing";
16 interface PostReportProps {
17 report: PostReportView;
20 export class PostReport extends Component<PostReportProps, any> {
21 constructor(props: any, context: any) {
22 super(props, context);
26 let r = this.props.report;
27 let resolver = r.resolver;
29 let tippyContent = i18n.t(
30 r.post_report.resolved ? "unresolve_report" : "resolve_report"
33 // Set the original post data ( a troll could change it )
34 post.name = r.post_report.original_post_name;
35 post.url = r.post_report.original_post_url;
36 post.body = r.post_report.original_post_body;
39 creator: r.post_creator,
40 community: r.community,
41 creator_banned_from_community: r.creator_banned_from_community,
43 subscribed: SubscribedType.NotSubscribed,
46 creator_blocked: false,
56 enableDownvotes={true}
64 {i18n.t("reporter")}: <PersonListing person={r.creator} />
67 {i18n.t("reason")}: {r.post_report.reason}
71 {r.post_report.resolved ? (
72 <T i18nKey="resolved_by">
74 <PersonListing person={resolver} />
77 <T i18nKey="unresolved_by">
79 <PersonListing person={resolver} />
85 className="btn btn-link btn-animate text-muted py-0"
86 onClick={linkEvent(this, this.handleResolveReport)}
87 data-tippy-content={tippyContent}
88 aria-label={tippyContent}
92 classes={`icon-inline ${
93 r.post_report.resolved ? "text-success" : "text-danger"
101 handleResolveReport(i: PostReport) {
104 let form: ResolvePostReport = {
105 report_id: i.props.report.post_report.id,
106 resolved: !i.props.report.post_report.resolved,
109 WebSocketService.Instance.send(wsClient.resolvePostReport(form));