From df6595694c678657fec30d881fb1edcd39b62f17 Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Fri, 15 Jan 2021 03:33:59 -0800 Subject: friend request --- src/utils/users.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/users.ts b/src/utils/users.ts index c54ea715..2a7db214 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -16,7 +16,7 @@ import {loadUserMomentCategories} from './../store/actions/momentCategories'; import {loadUserX} from './../store/actions/userX'; import {AppDispatch} from './../store/configureStore'; import {RootState} from './../store/rootReducer'; -import {ScreenType, UserType} from './../types/types'; +import {ProfilePreviewType, ProfileType, ScreenType, UserType} from './../types/types'; const loadData = async (dispatch: AppDispatch, user: UserType) => { await Promise.all([ @@ -122,3 +122,21 @@ export const getTokenOrLogout = async (dispatch: Function): Promise => { } return token; }; + +/** + * Creates ProfilePreviewType of a user using UserType && ProfileType + * @param passedInUser This is the UserType of the user + * @param passedInProfile This is the ProfileType of the user + */ +export const getUserAsProfilePreviewType = ( + passedInUser: UserType, + passedInProfile: ProfileType, +): ProfilePreviewType => { + const fullName = passedInProfile.name.split(' '); + return { + id: passedInUser.userId, + username: passedInUser.username, + first_name: fullName[0], + last_name: fullName[1], + }; +}; -- cgit v1.2.3-70-g09d2 From ed91266981e1662b512baa1856d8c921a8718e68 Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Fri, 15 Jan 2021 16:20:29 -0800 Subject: fixes --- src/components/common/AcceptDeclineButtons.tsx | 96 ++++++++++++++------------ src/components/notifications/Notification.tsx | 46 +++++------- src/components/profile/Content.tsx | 8 ++- src/components/profile/ProfileBody.tsx | 45 ++++++++++-- src/routes/Routes.tsx | 2 +- src/services/UserFriendsServices.ts | 2 +- src/store/actions/userFriends.ts | 1 - src/store/actions/userX.ts | 32 ++++++++- src/store/reducers/userXReducer.ts | 2 + src/utils/users.ts | 7 +- 10 files changed, 158 insertions(+), 83 deletions(-) (limited to 'src/utils') diff --git a/src/components/common/AcceptDeclineButtons.tsx b/src/components/common/AcceptDeclineButtons.tsx index 2ebae029..164ce6e7 100644 --- a/src/components/common/AcceptDeclineButtons.tsx +++ b/src/components/common/AcceptDeclineButtons.tsx @@ -1,5 +1,12 @@ import React from 'react'; -import {StyleSheet, View} from 'react-native'; +import { + StyleProp, + StyleSheet, + Text, + View, + ViewProps, + ViewStyle, +} from 'react-native'; import {Button} from 'react-native-elements'; import {useDispatch, useStore} from 'react-redux'; import { @@ -12,73 +19,72 @@ import {acceptFriendRequest} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {ProfilePreviewType} from '../../types'; import {SCREEN_WIDTH} from '../../utils'; +import {TouchableOpacity} from 'react-native-gesture-handler'; interface AcceptDeclineButtonsProps { requester: ProfilePreviewType; + onAccept: () => void; + onReject: () => void; + externalStyles?: Record>; } -const AcceptDeclineButtons: React.FC = (props) => { - const {requester} = props; - const state: RootState = useStore().getState(); - const dispatch = useDispatch(); - - const handleAcceptRequest = async () => { - dispatch(acceptFriendRequest(requester)); - dispatch(updateUserXFriends(requester.id, state)); - dispatch(loadUserNotifications()); - }; - - const handleDeclineFriendRequest = async () => { - dispatch(declineFriendRequest(requester.id)); - }; +const AcceptDeclineButtons: React.FC = ({ + requester, + onAccept, + onReject, + externalStyles, +}) => { return ( - <> -