|
@@ -1,15 +1,24 @@
|
|
-import React, { FC } from 'react';
|
|
|
|
|
|
+import React, { FC, useState } from 'react';
|
|
import { View, Text, ScrollView, TouchableOpacity, Linking } from 'react-native';
|
|
import { View, Text, ScrollView, TouchableOpacity, Linking } from 'react-native';
|
|
import { NavigationProp } from '@react-navigation/native';
|
|
import { NavigationProp } from '@react-navigation/native';
|
|
import { Formik } from 'formik';
|
|
import { Formik } from 'formik';
|
|
import * as yup from 'yup';
|
|
import * as yup from 'yup';
|
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
|
|
|
|
-import { PageWrapper, Header, Button, BigText, CheckBox, Input } from '../../../components';
|
|
|
|
|
|
+import {
|
|
|
|
+ PageWrapper,
|
|
|
|
+ Header,
|
|
|
|
+ Button,
|
|
|
|
+ BigText,
|
|
|
|
+ CheckBox,
|
|
|
|
+ Input,
|
|
|
|
+ WarningModal
|
|
|
|
+} from '../../../components';
|
|
import { NAVIGATION_PAGES } from '../../../types';
|
|
import { NAVIGATION_PAGES } from '../../../types';
|
|
import { useJoinTestMutation } from '@api/auth';
|
|
import { useJoinTestMutation } from '@api/auth';
|
|
import store from '../../../storage/zustand';
|
|
import store from '../../../storage/zustand';
|
|
import { styles } from './styles';
|
|
import { styles } from './styles';
|
|
|
|
+import { useNetInfo } from '@react-native-community/netinfo';
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
navigation: NavigationProp<any>;
|
|
navigation: NavigationProp<any>;
|
|
@@ -28,6 +37,8 @@ const JoinSchema = yup.object({
|
|
|
|
|
|
const JoinUsScreen: FC<Props> = ({ navigation }) => {
|
|
const JoinUsScreen: FC<Props> = ({ navigation }) => {
|
|
const { data, mutateAsync: JoinTest } = useJoinTestMutation();
|
|
const { data, mutateAsync: JoinTest } = useJoinTestMutation();
|
|
|
|
+ const [isWarningModalVisible, setIsWarningModalVisible] = useState(false);
|
|
|
|
+ const netInfo = useNetInfo();
|
|
|
|
|
|
const [updateRegistrationUserData] = store((state) => [
|
|
const [updateRegistrationUserData] = store((state) => [
|
|
state.registration.updateRegistrationUserData
|
|
state.registration.updateRegistrationUserData
|
|
@@ -51,6 +62,10 @@ const JoinUsScreen: FC<Props> = ({ navigation }) => {
|
|
validationSchema={JoinSchema}
|
|
validationSchema={JoinSchema}
|
|
onSubmit={(values) => {
|
|
onSubmit={(values) => {
|
|
const { email, username, password } = values;
|
|
const { email, username, password } = values;
|
|
|
|
+ if (!netInfo?.isInternetReachable) {
|
|
|
|
+ setIsWarningModalVisible(true);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
JoinTest({
|
|
JoinTest({
|
|
email,
|
|
email,
|
|
@@ -141,6 +156,11 @@ const JoinUsScreen: FC<Props> = ({ navigation }) => {
|
|
</KeyboardAwareScrollView>
|
|
</KeyboardAwareScrollView>
|
|
</View>
|
|
</View>
|
|
</ScrollView>
|
|
</ScrollView>
|
|
|
|
+ <WarningModal
|
|
|
|
+ isVisible={isWarningModalVisible}
|
|
|
|
+ onClose={() => setIsWarningModalVisible(false)}
|
|
|
|
+ type="offline"
|
|
|
|
+ />
|
|
</PageWrapper>
|
|
</PageWrapper>
|
|
);
|
|
);
|
|
};
|
|
};
|