diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-05-11 18:56:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-11 18:56:28 -0400 |
| commit | 68d10064cf1dcd2a774a4b2299f3a64f8fb75c60 (patch) | |
| tree | e8367c2a8cdb19e52c2a70b73ab2a89865efd54a /src/screens/profile/CommentReactionScreen.tsx | |
| parent | 610b6c9ddd2414b3b0d5c4cc24c35ef6e9e68513 (diff) | |
| parent | 51f397132d227edf5e07d48d673ee167d2aa5937 (diff) | |
Merge pull request #409 from IvanIFChen/tma799-comment-likes
[TMA-799] Comments likes
Diffstat (limited to 'src/screens/profile/CommentReactionScreen.tsx')
| -rw-r--r-- | src/screens/profile/CommentReactionScreen.tsx | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/screens/profile/CommentReactionScreen.tsx b/src/screens/profile/CommentReactionScreen.tsx new file mode 100644 index 00000000..0596a184 --- /dev/null +++ b/src/screens/profile/CommentReactionScreen.tsx @@ -0,0 +1,69 @@ +import {RouteProp, useNavigation} from '@react-navigation/native'; +import React, {useEffect, useState} from 'react'; +import {Alert, ScrollView, StyleSheet, View} from 'react-native'; +import {SafeAreaView} from 'react-native-safe-area-context'; +import {Friends} from '../../components'; +import {ERROR_SOMETHING_WENT_WRONG} from '../../constants/strings'; +import {MainStackParams} from '../../routes/main'; +import {getUsersReactedToAComment} from '../../services'; +import {ProfilePreviewType} from '../../types'; +import {HeaderHeight, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; + +type CommentReactionScreenRouteProps = RouteProp< + MainStackParams, + 'CommentReactionScreen' +>; + +interface CommentReactionScreenProps { + route: CommentReactionScreenRouteProps; +} + +const CommentReactionScreen: React.FC<CommentReactionScreenProps> = ({ + route, +}) => { + const navigation = useNavigation(); + const {comment, screenType} = route.params; + const [users, setUsers] = useState<ProfilePreviewType[]>([]); + + useEffect(() => { + const loadUsers = async () => { + const response = await getUsersReactedToAComment(comment); + if (response.length !== 0) { + setUsers(response); + } else { + Alert.alert(ERROR_SOMETHING_WENT_WRONG); + navigation.goBack(); + } + }; + loadUsers(); + }, []); + + return ( + <View style={styles.background}> + <SafeAreaView> + <ScrollView style={styles.container}> + <Friends + result={users} + screenType={screenType} + userId={undefined} + hideFriendsFeature + /> + </ScrollView> + </SafeAreaView> + </View> + ); +}; + +const styles = StyleSheet.create({ + background: { + backgroundColor: 'white', + width: SCREEN_WIDTH, + height: SCREEN_HEIGHT, + }, + container: { + marginTop: HeaderHeight, + height: SCREEN_HEIGHT - HeaderHeight, + }, +}); + +export default CommentReactionScreen; |
