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/components/common/AcceptDeclineButtons.tsx | 88 +++++++++++++++++++++ src/components/common/index.ts | 1 + src/components/notifications/Notification.tsx | 90 +++++++++++++++------ src/components/profile/Content.tsx | 67 +++++++++------- src/components/profile/ProfileBody.tsx | 100 ++++++++++++++++++++---- src/routes/Routes.tsx | 2 +- src/screens/onboarding/WelcomeScreen.tsx | 7 +- src/services/UserFriendsServices.ts | 104 +++++++++++++++++++++++-- src/services/UserProfileService.ts | 5 ++ src/store/actions/userFriends.ts | 102 +++++++++++++++++++++--- src/store/actions/userX.ts | 7 +- src/store/initialStates.ts | 2 + src/store/reducers/userXReducer.ts | 7 ++ src/types/types.ts | 6 +- src/utils/users.ts | 20 ++++- 15 files changed, 523 insertions(+), 85 deletions(-) create mode 100644 src/components/common/AcceptDeclineButtons.tsx (limited to 'src') diff --git a/src/components/common/AcceptDeclineButtons.tsx b/src/components/common/AcceptDeclineButtons.tsx new file mode 100644 index 00000000..2ebae029 --- /dev/null +++ b/src/components/common/AcceptDeclineButtons.tsx @@ -0,0 +1,88 @@ +import React from 'react'; +import {StyleSheet, View} from 'react-native'; +import {Button} from 'react-native-elements'; +import {useDispatch, useStore} from 'react-redux'; +import { + declineFriendRequest, + loadUserNotifications, + updateUserXFriends, +} from '../../store/actions'; +import {TAGG_TEXT_LIGHT_BLUE} from '../../constants'; +import {acceptFriendRequest} from '../../store/actions'; +import {RootState} from '../../store/rootReducer'; +import {ProfilePreviewType} from '../../types'; +import {SCREEN_WIDTH} from '../../utils'; + +interface AcceptDeclineButtonsProps { + requester: ProfilePreviewType; +} +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)); + }; + return ( + <> +