revite/src/pages/login/forms/FormReset.tsx

37 lines
963 B
TypeScript
Raw Normal View History

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