|
@@ -1,12 +1,13 @@
|
|
-import React, { FC } from 'react';
|
|
|
|
|
|
+import React, { FC, useState } from 'react';
|
|
import { Text, View } from 'react-native';
|
|
import { Text, View } from 'react-native';
|
|
import { Formik } from 'formik';
|
|
import { Formik } from 'formik';
|
|
import * as yup from 'yup';
|
|
import * as yup from 'yup';
|
|
|
|
|
|
-import { PageWrapper, Header, BigText, Button, Input } from '../../components/';
|
|
|
|
|
|
+import { PageWrapper, Header, BigText, Button, Input, WarningModal } from '../../components/';
|
|
|
|
|
|
import { styles } from './styles';
|
|
import { styles } from './styles';
|
|
import { useResetPasswordMutation } from '@api/auth';
|
|
import { useResetPasswordMutation } from '@api/auth';
|
|
|
|
+import { useNavigation } from '@react-navigation/native';
|
|
|
|
|
|
const ResetPasswordSchema = yup.object({
|
|
const ResetPasswordSchema = yup.object({
|
|
email: yup.string().email().required()
|
|
email: yup.string().email().required()
|
|
@@ -14,6 +15,8 @@ const ResetPasswordSchema = yup.object({
|
|
|
|
|
|
const ResetPasswordScreen: FC = () => {
|
|
const ResetPasswordScreen: FC = () => {
|
|
const { data, error, mutate: resetPassword } = useResetPasswordMutation();
|
|
const { data, error, mutate: resetPassword } = useResetPasswordMutation();
|
|
|
|
+ const [isModalVisible, setIsModalVisible] = useState(false);
|
|
|
|
+ const navigation = useNavigation();
|
|
|
|
|
|
return (
|
|
return (
|
|
<PageWrapper>
|
|
<PageWrapper>
|
|
@@ -23,9 +26,12 @@ const ResetPasswordScreen: FC = () => {
|
|
email: ''
|
|
email: ''
|
|
}}
|
|
}}
|
|
onSubmit={({ email }) => {
|
|
onSubmit={({ email }) => {
|
|
- resetPassword({
|
|
|
|
- email
|
|
|
|
- });
|
|
|
|
|
|
+ resetPassword(
|
|
|
|
+ {
|
|
|
|
+ email
|
|
|
|
+ },
|
|
|
|
+ { onSuccess: (res) => res.result === 'OK' && setIsModalVisible(true) }
|
|
|
|
+ );
|
|
}}
|
|
}}
|
|
validationSchema={ResetPasswordSchema}
|
|
validationSchema={ResetPasswordSchema}
|
|
>
|
|
>
|
|
@@ -55,6 +61,22 @@ const ResetPasswordScreen: FC = () => {
|
|
</>
|
|
</>
|
|
)}
|
|
)}
|
|
</Formik>
|
|
</Formik>
|
|
|
|
+ <WarningModal
|
|
|
|
+ isVisible={isModalVisible}
|
|
|
|
+ onClose={() => {
|
|
|
|
+ setIsModalVisible(false);
|
|
|
|
+ navigation.goBack();
|
|
|
|
+ }}
|
|
|
|
+ type={'success'}
|
|
|
|
+ message={
|
|
|
|
+ 'Password reset link has been sent to your email. Please check your inbox for further instructions.'
|
|
|
|
+ }
|
|
|
|
+ title="Success!"
|
|
|
|
+ action={() => {
|
|
|
|
+ setIsModalVisible(false);
|
|
|
|
+ navigation.goBack();
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
</PageWrapper>
|
|
</PageWrapper>
|
|
);
|
|
);
|
|
};
|
|
};
|