index.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { FC } from 'react';
  2. import { Text, View } from 'react-native';
  3. import { Formik } from 'formik';
  4. import * as yup from 'yup';
  5. import { PageWrapper, Header, BigText, Button, Input } from '../../components/';
  6. import { styles } from './styles';
  7. import { useResetPasswordMutation } from '../../modules/auth/api/queries/use-post-reset-password';
  8. const ResetPasswordSchema = yup.object({
  9. email: yup.string().email().required()
  10. });
  11. const ResetPasswordScreen: FC = () => {
  12. const { data, error, mutate: resetPassword } = useResetPasswordMutation();
  13. return (
  14. <PageWrapper>
  15. <Header label={'Reset Password'} />
  16. <Formik
  17. initialValues={{
  18. email: ''
  19. }}
  20. onSubmit={({ email }) => {
  21. resetPassword({
  22. email
  23. });
  24. }}
  25. validationSchema={ResetPasswordSchema}
  26. >
  27. {(props) => (
  28. <>
  29. <View style={{ gap: 15 }}>
  30. <BigText>Please enter your valid email</BigText>
  31. <Text style={styles.smallText}>
  32. Type email which you used for registration and check your inbox for further
  33. instructions
  34. </Text>
  35. <Input
  36. header={'Email address'}
  37. placeholder={'Email'}
  38. inputMode={'email'}
  39. onChange={props.handleChange('email')}
  40. value={props.values.email}
  41. onBlur={props.handleBlur('email')}
  42. formikError={
  43. data?.result_description || (props.touched.email && props.errors.email)
  44. }
  45. />
  46. </View>
  47. <View style={{ marginTop: '10%' }}>
  48. <Button onPress={props.handleSubmit}>Send</Button>
  49. </View>
  50. </>
  51. )}
  52. </Formik>
  53. </PageWrapper>
  54. );
  55. };
  56. export default ResetPasswordScreen;