import { setIsoData } from "@utils/app"; import { Component } from "inferno"; import { GetSiteResponse, VerifyEmailResponse } from "lemmy-js-client"; import { I18NextService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; interface State { verifyRes: RequestState; siteRes: GetSiteResponse; } export class VerifyEmail extends Component { private isoData = setIsoData(this.context); state: State = { verifyRes: { state: "empty" }, siteRes: this.isoData.site_res, }; constructor(props: any, context: any) { super(props, context); } async verify() { this.setState({ verifyRes: { state: "loading" }, }); this.setState({ verifyRes: await HttpService.client.verifyEmail({ token: this.props.match.params.token, }), }); if (this.state.verifyRes.state == "success") { toast(I18NextService.i18n.t("email_verified")); this.props.history.push("/login"); } } async componentDidMount() { await this.verify(); } get documentTitle(): string { return `${I18NextService.i18n.t("verify_email")} - ${ this.state.siteRes.site_view.site.name }`; } render() { return (
{I18NextService.i18n.t("verify_email")}
{this.state.verifyRes.state == "loading" && (
)}
); } }