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

33 lines
839 B
TypeScript
Raw Normal View History

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