From 96fda980905d0c7a30813c364c6623dda695012f Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Fri, 29 Jan 2021 15:14:26 -0800 Subject: full screen; with button; needs refresh&alignment; --- src/components/profile/Content.tsx | 26 ----------- src/components/profile/Friends.tsx | 83 +++++++++++++++++++++++++--------- src/components/profile/ProfileBody.tsx | 47 ++++++++++--------- 3 files changed, 84 insertions(+), 72 deletions(-) (limited to 'src/components/profile') diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index a35a5820..56ae1e51 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -216,31 +216,6 @@ const Content: React.FC = ({y, userXId, screenType}) => { } }, [blockedUsers, user]); - // Handles click on friend/requested/unfriend button - /* - * When user logged in clicks on the friend button: - A request is sent. - Which means you have to update the status of their friendshpi to requested - When the status is changed to requested the button should change to requested. - When the button is changed to requested and thr user clicks on it, - a request much go to the backend to delete that request - When that succeeds, their friendship must be updated to no-record again; - When the button is changed to no_record, the add friends button should be displayed again - */ - const handleFriendUnfriend = async () => { - const {friendship_status} = profile; - await dispatch( - friendUnfriendUser( - loggedInUser, - getUserAsProfilePreviewType(user, profile), - friendship_status, - screenType, - ), - ); - await dispatch(updateUserXFriends(user.userId, state)); - dispatch(updateUserXProfileAllScreens(user.userId, state)); - }; - /** * Handles a click on the block / unblock button. * loadFriends updates friends list for the logged in user @@ -332,7 +307,6 @@ const Content: React.FC = ({y, userXId, screenType}) => { userXId, screenType, isFriend, - handleFriendUnfriend, handleBlockUnblock, isBlocked, }} diff --git a/src/components/profile/Friends.tsx b/src/components/profile/Friends.tsx index 23ce28fe..5c724617 100644 --- a/src/components/profile/Friends.tsx +++ b/src/components/profile/Friends.tsx @@ -1,40 +1,53 @@ import React from 'react'; -import {View, StyleSheet, Text} from 'react-native'; +import {View, StyleSheet, Text, ScrollView} from 'react-native'; import {ProfilePreviewType, ScreenType} from '../../types'; import {ProfilePreview} from '..'; import {useNavigation} from '@react-navigation/native'; import {Button} from 'react-native-elements'; +import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; +import {TAGG_LIGHT_BLUE} from '../../constants'; +import {RootState} from '../../store/rootReducer'; +import {useDispatch, useStore} from 'react-redux'; +import {handleUnfriend} from '../../utils/friends'; interface FriendsProps { result: Array; screenType: ScreenType; + userXId: string; } -const Friends: React.FC = ({result, screenType}) => { +const Friends: React.FC = ({result, screenType, userXId}) => { const navigation = useNavigation(); + + const state: RootState = useStore().getState(); + const dispatch = useDispatch(); + return ( - <> - -