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 | |
parent | 0b338e0c243c63fc836c7a9829ef3787045bc034 (diff) |
finished likes screen
-rw-r--r-- | src/components/comments/CommentTile.tsx | 1 | ||||
-rw-r--r-- | src/constants/api.ts | 2 | ||||
-rw-r--r-- | src/screens/profile/CommentReactionScreen.tsx | 36 |
3 files changed, 22 insertions, 17 deletions
diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx index 688a16e6..e3364007 100644 --- a/src/components/comments/CommentTile.tsx +++ b/src/components/comments/CommentTile.tsx @@ -171,6 +171,7 @@ const CommentTile: React.FC<CommentTileProps> = ({ <View style={styles.row}> <TouchableOpacity style={styles.row} + disabled={commentObject.reaction_count === 0} onPress={() => { navigation.navigate('CommentReactionScreen', { comment: commentObject, diff --git a/src/constants/api.ts b/src/constants/api.ts index 1a31e815..2d9a60db 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -32,7 +32,7 @@ export const MOMENTS_ENDPOINT: string = API_URL + 'moments/'; export const MOMENT_THUMBNAIL_ENDPOINT: string = API_URL + 'moment-thumbnail/'; export const VERIFY_INVITATION_CODE_ENDPOUNT: string = API_URL + 'verify-code/'; export const COMMENTS_ENDPOINT: string = API_URL + 'comments/'; -export const COMMENT_REACTIONS_ENDPOINT: string = API_URL + 'react-comment/'; +export const COMMENT_REACTIONS_ENDPOINT: string = API_URL + 'reaction-comment/'; export const FRIENDS_ENDPOINT: string = API_URL + 'friends/'; export const ALL_USERS_ENDPOINT: string = API_URL + 'users/'; export const REPORT_ISSUE_ENDPOINT: string = API_URL + 'report/'; 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}> |