2021-06-18 15:21:54 -04:00
|
|
|
import { Form } from "./Form";
|
2021-06-18 17:47:25 -04:00
|
|
|
import { useContext } from "preact/hooks";
|
2021-06-18 15:21:54 -04:00
|
|
|
import { useHistory, useParams } from "react-router-dom";
|
2021-06-18 17:47:25 -04:00
|
|
|
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
2021-06-18 15:21:54 -04:00
|
|
|
|
|
|
|
export function FormSendReset() {
|
2021-06-18 17:47:25 -04:00
|
|
|
const { client } = useContext(AppContext);
|
|
|
|
|
2021-06-18 15:21:54 -04:00
|
|
|
return (
|
|
|
|
<Form
|
|
|
|
page="send_reset"
|
|
|
|
callback={async data => {
|
2021-06-18 17:47:25 -04:00
|
|
|
await client.req("POST", "/auth/send_reset", data);
|
2021-06-18 15:21:54 -04:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function FormReset() {
|
|
|
|
const { token } = useParams<{ token: string }>();
|
2021-06-18 17:47:25 -04:00
|
|
|
const { client } = useContext(AppContext);
|
2021-06-18 15:21:54 -04:00
|
|
|
const history = useHistory();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Form
|
|
|
|
page="reset"
|
|
|
|
callback={async data => {
|
2021-06-18 17:47:25 -04:00
|
|
|
await client.req("POST", "/auth/reset" as any, {
|
2021-06-18 15:21:54 -04:00
|
|
|
token,
|
|
|
|
...(data as any)
|
|
|
|
});
|
|
|
|
history.push("/login");
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|