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

40 lines
947 B
TypeScript
Raw Normal View History

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