|
@@ -1,47 +1,108 @@
|
|
|
-import React, { FC, useState } from 'react';
|
|
|
-import { View } from 'react-native';
|
|
|
+import React, { FC } from 'react';
|
|
|
+import { View, Text, ScrollView } from 'react-native';
|
|
|
import { NavigationProp } from '@react-navigation/native';
|
|
|
+import { Formik } from 'formik';
|
|
|
+import * as yup from 'yup';
|
|
|
|
|
|
import { PageWrapper, Header, Button, BigText, CheckBox, Input } from '../../../components';
|
|
|
import { NAVIGATION_PAGES } from '../../../types';
|
|
|
+import store from '../../../storage/zustand';
|
|
|
|
|
|
type Props = {
|
|
|
navigation: NavigationProp<any>;
|
|
|
};
|
|
|
|
|
|
+const JoinSchema = yup.object({
|
|
|
+ username: yup.string().required('username is required').min(4),
|
|
|
+ email: yup.string().required('email is required').email('enter valid email'),
|
|
|
+ password: yup.string().required('password is required').min(8),
|
|
|
+ repeatPassword: yup
|
|
|
+ .string()
|
|
|
+ .required('repeat your password')
|
|
|
+ .oneOf([yup.ref('password'), 'repeat password'], 'passwords must match'),
|
|
|
+ checkboxAgreed: yup.bool().isTrue()
|
|
|
+});
|
|
|
+
|
|
|
const JoinUsScreen: FC<Props> = ({ navigation }) => {
|
|
|
- const [agreed, setAgreed] = useState(false);
|
|
|
+ const [updateRegistrationUserData] = store((state) => [
|
|
|
+ state.registration.updateRegistrationUserData
|
|
|
+ ]);
|
|
|
|
|
|
return (
|
|
|
<PageWrapper>
|
|
|
- <Header label={'Sign Up'} />
|
|
|
- <View style={{ gap: 15 }}>
|
|
|
- <BigText>Join us. It's free!</BigText>
|
|
|
- <Input onChange={() => {}} placeholder={'Text'} header={'Username'} />
|
|
|
- <Input
|
|
|
- onChange={() => {}}
|
|
|
- placeholder={'Email'}
|
|
|
- inputMode={'email'}
|
|
|
- header={'Email address'}
|
|
|
- />
|
|
|
- <Input onChange={() => {}} placeholder={'Text'} isPrivate={true} header={'Password'} />
|
|
|
- <Input
|
|
|
- onChange={() => {}}
|
|
|
- placeholder={'Text'}
|
|
|
- isPrivate={true}
|
|
|
- header={'Confirm password'}
|
|
|
- />
|
|
|
- <CheckBox
|
|
|
- label={'I accept NM Terms & Conditions'}
|
|
|
- onChange={(b) => setAgreed(b)}
|
|
|
- value={agreed}
|
|
|
- />
|
|
|
- </View>
|
|
|
- <View style={{ marginTop: '15%' }}>
|
|
|
- <Button onPress={() => navigation.navigate(NAVIGATION_PAGES.REGISTER_ACCOUNT_DATA)}>
|
|
|
- Continue
|
|
|
- </Button>
|
|
|
- </View>
|
|
|
+ <ScrollView showsVerticalScrollIndicator={false}>
|
|
|
+ <Header label={'Sign Up'} />
|
|
|
+ <View style={{ gap: 15 }}>
|
|
|
+ <BigText>Join us. It's free!</BigText>
|
|
|
+ <Formik
|
|
|
+ initialValues={{
|
|
|
+ email: '',
|
|
|
+ username: '',
|
|
|
+ password: '',
|
|
|
+ repeatPassword: '',
|
|
|
+ checkboxAgreed: false
|
|
|
+ }}
|
|
|
+ validationSchema={JoinSchema}
|
|
|
+ onSubmit={(values) => {
|
|
|
+ navigation.navigate(NAVIGATION_PAGES.REGISTER_ACCOUNT_DATA);
|
|
|
+
|
|
|
+ const { email, username, password } = values;
|
|
|
+ updateRegistrationUserData({ email, username, password });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {(props) => (
|
|
|
+ <View style={{ gap: 15 }}>
|
|
|
+ <Input
|
|
|
+ onChange={props.handleChange('username')}
|
|
|
+ value={props.values.username}
|
|
|
+ onBlur={props.handleBlur('username')}
|
|
|
+ placeholder={'Enter your username'}
|
|
|
+ header={'Username'}
|
|
|
+ formikError={props.touched.username && props.errors.username}
|
|
|
+ />
|
|
|
+ <Input
|
|
|
+ onChange={props.handleChange('email')}
|
|
|
+ value={props.values.email}
|
|
|
+ onBlur={props.handleBlur('email')}
|
|
|
+ placeholder={'Enter your email'}
|
|
|
+ header={'Email address'}
|
|
|
+ inputMode={'email'}
|
|
|
+ formikError={props.touched.email && props.errors.email}
|
|
|
+ />
|
|
|
+ <Input
|
|
|
+ onChange={props.handleChange('password')}
|
|
|
+ value={props.values.password}
|
|
|
+ onBlur={props.handleBlur('password')}
|
|
|
+ placeholder={'Enter your password'}
|
|
|
+ header={'Password'}
|
|
|
+ isPrivate={true}
|
|
|
+ formikError={props.touched.password && props.errors.password}
|
|
|
+ />
|
|
|
+ <Input
|
|
|
+ onChange={props.handleChange('repeatPassword')}
|
|
|
+ value={props.values.repeatPassword}
|
|
|
+ onBlur={props.handleBlur('repeatPassword')}
|
|
|
+ placeholder={'Repeat your password'}
|
|
|
+ header={'Confirm password'}
|
|
|
+ isPrivate={true}
|
|
|
+ formikError={props.touched.repeatPassword && props.errors.repeatPassword}
|
|
|
+ />
|
|
|
+ <CheckBox
|
|
|
+ label={'I accept NM Terms & Conditions'}
|
|
|
+ onChange={(value) => props.setFieldValue('checkboxAgreed', value)}
|
|
|
+ value={props.values.checkboxAgreed}
|
|
|
+ />
|
|
|
+ <Text>
|
|
|
+ {props.touched.checkboxAgreed && props.errors.checkboxAgreed
|
|
|
+ ? 'To use our service you need to agree'
|
|
|
+ : null}
|
|
|
+ </Text>
|
|
|
+ <Button onPress={props.handleSubmit}>Continue</Button>
|
|
|
+ </View>
|
|
|
+ )}
|
|
|
+ </Formik>
|
|
|
+ </View>
|
|
|
+ </ScrollView>
|
|
|
</PageWrapper>
|
|
|
);
|
|
|
};
|