import * as React from "react"; import axios from "axios"; import { error as log, init as logInit } from "../toast/toast"; import { prettyPrintApiErrors } from "../util"; import { API } from "../api"; import { Widget, WidgetHeader, WidgetBody, Row, Col } from "../ui/index"; import { Session } from "../session"; import { t } from "../i18next_wrapper"; export interface State { password?: string; passwordConfirmation?: string; serverURL?: string; serverPort?: string; } export interface Props { } export class PasswordReset extends React.Component { constructor(props: Props) { super(props); this.state = { password: "", passwordConfirmation: "", serverURL: "", serverPort: "" }; } componentDidMount() { logInit(); API.setBaseUrl(API.fetchBrowserLocation()); this.setState({ serverURL: API.fetchHostName(), serverPort: API.inferPort() }); } set = (name: string) => (event: React.FormEvent) => { const state: { [name: string]: string } = {}; state[name] = (event.currentTarget).value; this.setState(state); }; submit(e: React.SyntheticEvent) { e.preventDefault(); const { password, passwordConfirmation } = this.state; const token = window.location.href.split("/").pop(); axios.put(API.current.passwordResetPath, { id: token, password, password_confirmation: passwordConfirmation, }) .then(Session.clear) .catch((error: string) => { log(prettyPrintApiErrors(error as {})); }); } render() { const buttonStylesUniqueToOnlyThisPage = { marginTop: "1rem", padding: ".5rem 1.6rem", fontSize: "1.2rem", borderBottom: "none" }; return

{t("Reset your password")}


; } }