+
Log In
diff --git a/src/components/Auth/ResetPassword.tsx b/src/components/Auth/ResetPassword.tsx
new file mode 100644
index 0000000..29495ea
--- /dev/null
+++ b/src/components/Auth/ResetPassword.tsx
@@ -0,0 +1,83 @@
+import { useState } from 'react';
+import {
+ Form,
+ Input,
+ Button,
+ Divider,
+} from 'antd';
+import { MailOutlined } from '@ant-design/icons';
+import {
+ Link,
+ useHistory,
+} from 'react-router-dom';
+import { useAuth } from '../../contexts/AuthContext';
+import { Routes } from '../../routes';
+import validateMessages from './validateMessages';
+import {
+ resetFailed,
+ resetSuccessful,
+} from './notifications';
+import { containerStyle } from './common';
+
+const { Item } = Form;
+
+const ResetPassword = () => {
+ const [form] = Form.useForm();
+ const [isLoading, setIsLoading] = useState(false);
+ const { resetPassword } = useAuth();
+ const history = useHistory();
+
+ const onFinish = async ({ email, password }: { form: any, email: string, password: string }) => {
+ setIsLoading(true);
+ try {
+ await resetPassword(email);
+ resetSuccessful();
+ history.push(Routes.LOGIN);
+ } catch (error) {
+ form.resetFields();
+ console.warn(error);
+ resetFailed(error as Error);
+ setIsLoading(false);
+ }
+ };
+
+ return (
+
+ );
+};
+
+export default ResetPassword;
diff --git a/src/components/Auth/SignUp.tsx b/src/components/Auth/SignUp.tsx
index dc96acd..4f2bd63 100644
--- a/src/components/Auth/SignUp.tsx
+++ b/src/components/Auth/SignUp.tsx
@@ -4,7 +4,6 @@ import {
Input,
Button,
Divider,
- notification,
} from 'antd';
import {
MailOutlined,
@@ -17,7 +16,12 @@ import {
import { useAuth } from '../../contexts/AuthContext';
import { Routes } from '../../routes';
import validateMessages from './validateMessages';
-import emailNotVerifiedWarning from './emailNotVerifiedWarning';
+import {
+ emailNotVerified,
+ signUpFailed,
+ signUpSuccessful,
+} from './notifications';
+import { containerStyle } from './common';
const { Item } = Form;
@@ -33,30 +37,19 @@ const SignUp = () => {
setIsLoading(true);
try {
await signUp(email, password);
- notification.success({
- message: 'Sign Up successful',
- description: 'Welcome on board!',
- });
- emailNotVerifiedWarning();
-
+ signUpSuccessful();
+ emailNotVerified();
history.push(Routes.ROOT);
- } catch (err) {
+ } catch (error) {
form.resetFields();
- console.warn(err);
- notification.error({
- message: 'Failed to create an account',
- description: (err as Error).message,
- });
+ console.warn(error);
+ signUpFailed(error as Error);
setIsLoading(false);
}
};
return (
-