Browse Source

Merge branch 'reset-password-fix' of SashaGoncharov19/nomadmania-app into dev

Viktoriia 1 year ago
parent
commit
7903746b5d
2 changed files with 30 additions and 7 deletions
  1. 3 2
      app.config.ts
  2. 27 5
      src/screens/ResetPasswordScreen/index.tsx

+ 3 - 2
app.config.ts

@@ -71,7 +71,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
     config: {
     config: {
       googleMaps: {
       googleMaps: {
         apiKey: env.ANDROID_GOOGLE_MAP_APIKEY
         apiKey: env.ANDROID_GOOGLE_MAP_APIKEY
-      }
+      },
     },
     },
     permissions: [
     permissions: [
       'ACCESS_BACKGROUND_LOCATION',
       'ACCESS_BACKGROUND_LOCATION',
@@ -98,7 +98,8 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
       "expo-build-properties",
       "expo-build-properties",
       {
       {
         android: {
         android: {
-          minSdkVersion: 33
+          minSdkVersion: 24,
+          targetSdkVersion: 33
         }
         }
       }
       }
     ],
     ],

+ 27 - 5
src/screens/ResetPasswordScreen/index.tsx

@@ -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>
   );
   );
 };
 };