diff options
author | Ashm Walia <40498934+ashmgarv@users.noreply.github.com> | 2020-10-13 13:13:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 16:13:45 -0400 |
commit | 2bd196c6165cbf45544dbc0a021daf5d313fde3c (patch) | |
tree | 3e1b138f7d3467384391522edf1b237cec82a893 /src | |
parent | 854a7d8f8526e8142c416ec41682468e87bcbbd2 (diff) |
[TMA-238] (Small change) Do not skip invitation code verification (#54)
* Do not skip invitation code verification
* Check code length before calling the backend API
* Nitpick
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/api.ts | 4 | ||||
-rw-r--r-- | src/screens/onboarding/InvitationCodeVerification.tsx | 61 |
2 files changed, 30 insertions, 35 deletions
diff --git a/src/constants/api.ts b/src/constants/api.ts index 86b941d0..fa8cd0b3 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -12,6 +12,4 @@ export const COVER_PHOTO_ENDPOINT: string = API_URL + 'large-profile-pic/'; export const AVATAR_PHOTO_ENDPOINT: string = API_URL + 'small-profile-pic/'; export const GET_IG_POSTS_ENDPOINT: string = API_URL + 'posts-ig/'; export const SEARCH_ENDPOINT: string = API_URL + 'search/'; - -//TODO add an endpoint to verify the invitation code, such as below -//export const VERIFY_INVITATION_CODE_ENDPOUNT: string = API_URL + 'verify_invitation_code/'; +export const VERIFY_INVITATION_CODE_ENDPOUNT: string = API_URL + 'verify-code/'; 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} |