1 import { None } from "@sniptt/monads/build";
2 import { Component } from "inferno";
6 VerifyEmail as VerifyEmailForm,
10 } from "lemmy-js-client";
11 import { Subscription } from "rxjs";
12 import { i18n } from "../../i18next";
13 import { WebSocketService } from "../../services";
21 import { HtmlTags } from "../common/html-tags";
24 verifyEmailForm: VerifyEmailForm;
25 siteRes: GetSiteResponse;
28 export class VerifyEmail extends Component<any, State> {
29 private isoData = setIsoData(this.context);
30 private subscription: Subscription;
33 verifyEmailForm: new VerifyEmailForm({
34 token: this.props.match.params.token,
36 siteRes: this.isoData.site_res,
39 constructor(props: any, context: any) {
40 super(props, context);
42 this.state = this.emptyState;
44 this.parseMessage = this.parseMessage.bind(this);
45 this.subscription = wsSubscribe(this.parseMessage);
49 WebSocketService.Instance.send(
50 wsClient.verifyEmail(this.state.verifyEmailForm)
54 componentWillUnmount() {
56 this.subscription.unsubscribe();
60 get documentTitle(): string {
61 return `${i18n.t("verify_email")} - ${
62 this.state.siteRes.site_view.site.name
68 <div className="container-lg">
70 title={this.documentTitle}
71 path={this.context.router.route.match.url}
76 <div className="col-12 col-lg-6 offset-lg-3 mb-4">
77 <h5>{i18n.t("verify_email")}</h5>
84 parseMessage(msg: any) {
85 let op = wsUserOp(msg);
88 toast(i18n.t(msg.error), "danger");
89 this.setState(this.state);
90 this.props.history.push("/");
92 } else if (op == UserOperation.VerifyEmail) {
93 let data = wsJsonToRes<VerifyEmailResponse>(msg, VerifyEmailResponse);
95 toast(i18n.t("email_verified"));
96 this.setState(this.emptyState);
97 this.props.history.push("/login");