diff options
| author | Ivan Chen <ivan@thetaggid.com> | 2021-01-13 02:58:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-13 02:58:24 -0500 |
| commit | 353c1ec685698bb86e0ff96a346d88205ee389cf (patch) | |
| tree | 021f721cc8eb94ab007183c39d808e9eb3a468e8 /src/services | |
| parent | 5664f30a218af4620be69c66f4aba93d5972f890 (diff) | |
[TMA-531] New Explore Page (#179)
* redux done
* done
* added refresh control
* added profile navigation
* minor spacing change
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/ExploreServices.ts | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/services/ExploreServices.ts b/src/services/ExploreServices.ts index 2181ea7d..ca4f1b69 100644 --- a/src/services/ExploreServices.ts +++ b/src/services/ExploreServices.ts @@ -1,4 +1,8 @@ -import {ALL_USERS_ENDPOINT} from '../constants'; +import AsyncStorage from '@react-native-community/async-storage'; +import {getDeviceToken} from 'react-native-device-info'; +import {ALL_USERS_ENDPOINT, DISCOVER_ENDPOINT} from '../constants'; +import {EMPTY_EXPLORE_SECTIONS} from '../store/initialStates'; +import {ExploreSectionType, ProfilePreviewType} from '../types'; export const getAllTaggUsers = async (token: string) => { try { @@ -26,3 +30,31 @@ export const getAllTaggUsers = async (token: string) => { ); } }; + +export const getAllExploreSections = async () => { + try { + const token = await AsyncStorage.getItem('token'); + const response = await fetch(DISCOVER_ENDPOINT, { + method: 'GET', + headers: { + Authorization: 'Token ' + token, + }, + }); + if (response.status !== 200) { + return EMPTY_EXPLORE_SECTIONS; + } + const data = await response.json(); + const exploreSections: Record<ExploreSectionType, ProfilePreviewType[]> = { + 'New to Tagg': data.categories.new_to_tagg, + 'People You May Know': data.categories.people_you_may_know, + 'Trending on Tagg': data.categories.trending_on_tagg, + "Brown '21": data.categories.brown_21, + "Brown '22": data.categories.brown_22, + "Brown '23": data.categories.brown_23, + }; + + return exploreSections; + } catch (error) { + console.log('Unable to fetch explore data'); + } +}; |
