diff options
Diffstat (limited to 'src/components/profile/ProfileBody.tsx')
-rw-r--r-- | src/components/profile/ProfileBody.tsx | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx index f2d75519..106b20a7 100644 --- a/src/components/profile/ProfileBody.tsx +++ b/src/components/profile/ProfileBody.tsx @@ -9,14 +9,17 @@ import { import ToggleButton from './ToggleButton'; import {RootState} from '../../store/rootReducer'; import {useDispatch, useSelector, useStore} from 'react-redux'; -import {FriendshipStatusType, ScreenType} from '../../types'; -import {NO_PROFILE} from '../../store/initialStates'; -import {getUserAsProfilePreviewType, SCREEN_WIDTH} from '../../utils'; -import {AcceptDeclineButtons} from '../common'; +import {ScreenType} from '../../types'; +import {NO_PROFILE, NO_USER} from '../../store/initialStates'; +import { + getUserAsProfilePreviewType, + handleFriendUnfriend, + SCREEN_WIDTH, +} from '../../utils'; +import {AcceptDeclineButtons, FriendsButton} from '../common'; import { acceptFriendRequest, declineFriendRequest, - loadUserNotifications, updateUserXFriends, updateUserXProfileAllScreens, } from '../../store/actions'; @@ -24,7 +27,6 @@ import { interface ProfileBodyProps { onLayout: (event: LayoutChangeEvent) => void; isBlocked: boolean; - handleFriendUnfriend: () => void; handleBlockUnblock: () => void; userXId: string | undefined; screenType: ScreenType; @@ -32,7 +34,6 @@ interface ProfileBodyProps { const ProfileBody: React.FC<ProfileBodyProps> = ({ onLayout, isBlocked, - handleFriendUnfriend, handleBlockUnblock, userXId, screenType, @@ -41,6 +42,10 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({ ? useSelector((state: RootState) => state.userX[screenType][userXId]) : useSelector((state: RootState) => state.user); + const {user: loggedInUser = NO_USER} = useSelector( + (state: RootState) => state.user, + ); + const { biography, website, @@ -94,29 +99,23 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({ )} {userXId && !isBlocked && ( <View style={styles.buttonsContainer}> - {friendship_status === 'no_record' && ( - <Button - title={'Add Friend'} - buttonStyle={styles.button} - titleStyle={styles.buttonTitle} - onPress={handleFriendUnfriend} // requested, requested status - /> - )} - {friendship_status === 'friends' && ( - <Button - title={'Unfriend'} - buttonStyle={styles.requestedButton} - titleStyle={styles.requestedButtonTitle} - onPress={handleFriendUnfriend} // unfriend, no record status - /> - )} + <FriendsButton userXId={userXId} screenType={screenType} /> {(friendship_status === 'requested' && friendship_requester_id !== userXId && ( <Button title={'Requested'} buttonStyle={styles.requestedButton} titleStyle={styles.requestedButtonTitle} - onPress={handleFriendUnfriend} // delete request, no record status + onPress={() => + handleFriendUnfriend( + screenType, + user, + profile, + dispatch, + state, + loggedInUser, + ) + } // delete request, no record status /> )) || (friendship_status === 'requested' && |