diff options
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}> |