diff options
| author | Ashm Walia <40498934+ashmgarv@users.noreply.github.com> | 2021-01-12 13:35:33 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-12 16:35:33 -0500 |
| commit | c758389ad2ebe98196d4618ec08dbf2b24d95bfa (patch) | |
| tree | 1db37ccbe08d65dc689e0e9fd733aaf711681431 /src/services | |
| parent | 251c44edf33dd303ad5255cca95174eb72428543 (diff) | |
[TMA 472] Added option to be added to Taggs wait list (#168)
* Added screens to add to waitlist and a page to display on success of the same
* Incorporated small comment
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/WaitlistUserService.tsx | 45 | ||||
| -rw-r--r-- | src/services/index.ts | 1 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/services/WaitlistUserService.tsx b/src/services/WaitlistUserService.tsx new file mode 100644 index 00000000..516affe3 --- /dev/null +++ b/src/services/WaitlistUserService.tsx @@ -0,0 +1,45 @@ +import {Alert} from 'react-native'; +import {WAITLIST_USER_ENDPOINT} from '../constants'; + +export const adduserToWaitlist: ( + phone_number: string, + first_name: string, + last_name: string, +) => Promise<boolean> = async (phone_number, first_name, last_name) => { + try { + console.log(phone_number, first_name, last_name); + const response = await fetch(WAITLIST_USER_ENDPOINT, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + phone_number, + first_name, + last_name, + }), + }); + const status = response.status; + const message = await response.json(); + if (status === 200) { + return true; + } else { + if (status === 409) { + Alert.alert('You are already on our waitlist / on our app'); + } else if (status === 400) { + Alert.alert('Some information needed was missing / ill-formatted'); + } else if (status === 500) { + Alert.alert( + 'Something went wrong. Sorry unable to add you to the waitlist 😔', + ); + } + console.log(message); + } + } catch (err) { + Alert.alert( + 'Something went wrong. Sorry unable to add you to the waitlist 😔', + ); + console.log(err); + } + return false; +}; diff --git a/src/services/index.ts b/src/services/index.ts index 7ea5bf5d..56cefddd 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -8,3 +8,4 @@ export * from './BlockUserService'; export * from './MomentCategoryService'; export * from './NotificationService'; export * from './FCMService'; +export * from './WaitlistUserService'; |
