diff options
Diffstat (limited to 'src/screens/onboarding/InvitationCodeVerification.tsx')
-rw-r--r-- | src/screens/onboarding/InvitationCodeVerification.tsx | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/src/screens/onboarding/InvitationCodeVerification.tsx b/src/screens/onboarding/InvitationCodeVerification.tsx index ae1c282f..9af288b4 100644 --- a/src/screens/onboarding/InvitationCodeVerification.tsx +++ b/src/screens/onboarding/InvitationCodeVerification.tsx @@ -10,8 +10,7 @@ import { LoadingIndicator, } from '../../components'; -//TODO : -//import {VERIFY_INVITATION_CODE_ENDPOUNT} from "../../constants" +import {VERIFY_INVITATION_CODE_ENDPOUNT} from "../../constants" import {Text} from 'react-native-animatable'; import { @@ -54,35 +53,33 @@ const InvitationCodeVerification: React.FC<InvitationCodeVerificationProps> = ({ }); const handleInvitationCodeVerification = async () => { - //TODO : Verify the code - //The code would look somewhat like below - // try { - // let verifyInviteCodeResponse = await fetch(VERIFY_INVITATION_CODE_ENDPOUNT, { - // method: 'POST', - // body: JSON.stringify({ - // otp: value, - // }), - // }); + if(value.length == 6){ + try { + let verifyInviteCodeResponse = await fetch(VERIFY_INVITATION_CODE_ENDPOUNT + value + '/', { + method: 'DELETE', + }); - // if (verifyInviteCodeResponse.status == 200) { - // navigation.navigate('RegistrationOne'); - // } else { - // Alert.alert( - // 'Invalid invitation code 🤔', - // ); - // } - // } catch (error) { - // Alert.alert( - // 'Verifiation failed 😓', - // 'Please double-check your network connection and retry.', - // ); - // return { - // name: 'Verification error', - // description: error, - // }; - // } - - navigation.navigate('RegistrationOne'); + if (verifyInviteCodeResponse.status == 200) { + navigation.navigate('RegistrationOne'); + } else { + Alert.alert( + 'Invalid invitation code 🤔', + ); + } + } catch (error) { + Alert.alert( + 'Verifiation failed 😓', + 'Please double-check your network connection and retry.', + ); + return { + name: 'Verification error', + description: error, + }; + } + } + else{ + Alert.alert("The code entered is not valid!"); + } }; const Footer = () => ( @@ -98,9 +95,9 @@ const InvitationCodeVerification: React.FC<InvitationCodeVerificationProps> = ({ <Background centered style={styles.container}> <RegistrationWizard style={styles.wizard} step="one" /> <KeyboardAvoidingView behavior="padding" style={styles.form}> - <Text style={styles.formHeader}>Enter 6 digit code</Text> + <Text style={styles.formHeader}>Enter the code</Text> <Text style={styles.description}> - Please enter the invitation code provided to you by us / your friend. + Please enter the invitation code provided to you by us / your friend. (Use all caps.) </Text> <CodeField ref={ref} |