diff options
author | Ivan Chen <ivan@tagg.id> | 2021-05-10 16:37:11 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-05-10 16:50:42 -0400 |
commit | c3f7b66e4941d3bc0a0406e46f3b8fce5e01329e (patch) | |
tree | aefb24f10c5e213bd74f14682b7aff5850d58af0 /src/screens/profile/CommentReactionScreen.tsx | |
parent | 0b338e0c243c63fc836c7a9829ef3787045bc034 (diff) |
finished likes screen
Diffstat (limited to 'src/screens/profile/CommentReactionScreen.tsx')
-rw-r--r-- | src/screens/profile/CommentReactionScreen.tsx | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/screens/profile/CommentReactionScreen.tsx b/src/screens/profile/CommentReactionScreen.tsx index 1bda2a65..23a1f768 100644 --- a/src/screens/profile/CommentReactionScreen.tsx +++ b/src/screens/profile/CommentReactionScreen.tsx @@ -1,20 +1,14 @@ -import {RouteProp} from '@react-navigation/native'; +import {RouteProp, useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; -import {ScrollView, StatusBar, StyleSheet, View} from 'react-native'; +import {Alert, ScrollView, StyleSheet, View} from 'react-native'; import {SafeAreaView} from 'react-native-safe-area-context'; -import {useSelector, useStore} from 'react-redux'; import {Friends} from '../../components'; +import {ERROR_SOMETHING_WENT_WRONG} from '../../constants/strings'; import {MainStackParams} from '../../routes/main'; -import {RootState} from '../../store/rootReducer'; -import {ProfilePreviewType, ScreenType} from '../../types'; +import {getUsersReactedToAComment} from '../../services'; +import {ProfilePreviewType} from '../../types'; import {HeaderHeight, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; -/** - * Comments Screen for an image uploaded - * Displays all comments for a particular moment uploaded by the user followed by a text area to add the comment. - * Comment is posted when return is pressed on the keypad. - */ - type CommentReactionScreenRouteProps = RouteProp< MainStackParams, 'CommentReactionScreen' @@ -27,13 +21,23 @@ interface CommentReactionScreenProps { const CommentReactionScreen: React.FC<CommentReactionScreenProps> = ({ route, }) => { + const navigation = useNavigation(); const {comment, screenType} = route.params; - // const [users, setUsers] = useState<ProfilePreviewType[]>([]); - const {friends: users} = useSelector((state: RootState) => state.friends); - - useEffect(() => {}, []); + const [users, setUsers] = useState<ProfilePreviewType[]>([]); - console.log(screenType); + useEffect(() => { + const loadUsers = async () => { + const response = await getUsersReactedToAComment(comment); + if (response.length !== 0) { + console.log(response); + setUsers(users); + } else { + Alert.alert(ERROR_SOMETHING_WENT_WRONG); + navigation.goBack(); + } + }; + loadUsers(); + }, []); return ( <View style={styles.background}> |