Files
score/src/new-frontend/src/pages/RecoverPassword.tsx
Alejandra e44777f919 Restructure folders, allow editing of users/items, and implement other refactors and improvements (#603)
* Reorganize project directory structure

* Allow edit users/items, add useAuth and useCustomToast, password confirmation

* Minor improvements for consistency

* Add 'Cancel' button to UserInformation in editMode

* Refactor UserSettings

* Enable user password changes and improve error handling

* Enable user information update

* Add logout to Sidebar in mobile devices, conditional tabs depending on role and other improvements

* Add badges

* Remove comment

* Appearance tab updates

* Change badge color

* Reset inputs when clicking on 'Cancel' button

* Disable actions menu for Superuser when logged in

* Modify Logout and update stores
2024-02-26 15:39:09 +01:00

60 lines
1.5 KiB
TypeScript

import React from "react";
import { Button, Container, FormControl, Heading, Input, Text } from "@chakra-ui/react";
import { SubmitHandler, useForm } from "react-hook-form";
import { LoginService } from "../client";
import useCustomToast from "../hooks/useCustomToast";
interface FormData {
email: string;
}
const RecoverPassword: React.FC = () => {
const { register, handleSubmit } = useForm<FormData>();
const showToast = useCustomToast();
const onSubmit: SubmitHandler<FormData> = async (data) => {
const response = await LoginService.recoverPassword({
email: data.email,
});
console.log(response)
showToast("Email sent.", "We sent an email with a link to get back into your account.", "success");
};
return (
<Container
as="form"
onSubmit={handleSubmit(onSubmit)}
h="100vh"
maxW="sm"
alignItems="stretch"
justifyContent="center"
gap={4}
centerContent
>
<Heading size="xl" color="ui.main" textAlign="center" mb={2}>
Password Recovery
</Heading>
<FormControl id="username">
<Text align="center">
A password recovery email will be sent to the registered account.
</Text>
<Input
{...register("email")}
mt={4}
placeholder="Enter your email"
type="text"
/>
</FormControl>
<Button bg="ui.main" color="white" _hover={{ opacity: 0.8 }} type="submit">
Continue
</Button>
</Container>
);
};
export default RecoverPassword;