diff options
author | Ashm Walia <ashmwalia@outlook.com> | 2021-01-15 16:20:29 -0800 |
---|---|---|
committer | Ashm Walia <ashmwalia@outlook.com> | 2021-01-15 16:20:29 -0800 |
commit | ed91266981e1662b512baa1856d8c921a8718e68 (patch) | |
tree | 10d61d494885f01427973fb430b3e2d1d47ce3c1 /src/components/notifications/Notification.tsx | |
parent | df6595694c678657fec30d881fb1edcd39b62f17 (diff) |
fixes
Diffstat (limited to 'src/components/notifications/Notification.tsx')
-rw-r--r-- | src/components/notifications/Notification.tsx | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 5e68c6f3..42b10ea3 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -97,22 +97,16 @@ const Notification: React.FC<NotificationProps> = (props) => { } }; - // const handleAcceptRequest = async () => { - // const requester: ProfilePreviewType = { - // id: id, - // username: username, - // first_name: first_name, - // last_name: last_name, - // }; - // dispatch(acceptFriendRequest(requester)); - // dispatch(updateUserXFriends(id, state)); - // console.log('fetching notifications since user accepted request!'); - // dispatch(loadUserNotifications()); - // }; + const handleAcceptRequest = async () => { + await dispatch(acceptFriendRequest({id, username, first_name, last_name})); + await dispatch(updateUserXFriends(id, state)); + dispatch(loadUserNotifications()); + }; - // const handleDeclineFriendRequest = async () => { - // dispatch(declineFriendRequest(id)); - // }; + const handleDeclineFriendRequest = async () => { + await dispatch(declineFriendRequest(id)); + dispatch(loadUserNotifications()); + }; return ( <> @@ -135,6 +129,15 @@ const Notification: React.FC<NotificationProps> = (props) => { </Text> <Text>{verbage}</Text> </View> + {notification_type === 'FRD_REQ' && ( + <View style={styles.buttonsContainer}> + <AcceptDeclineButtons + requester={{id, username, first_name, last_name}} + onAccept={handleAcceptRequest} + onReject={handleDeclineFriendRequest} + /> + </View> + )} </TouchableWithoutFeedback> {/* TODO: Still WIP */} {/* {notification_type === 'CMT' && notification_object && ( @@ -143,13 +146,6 @@ const Notification: React.FC<NotificationProps> = (props) => { source={{uri: momentURI, cache: 'only-if-cached'}} /> )} */} - {notification_type === 'FRD_REQ' && ( - <View style={styles.buttonsContainer}> - <AcceptDeclineButtons - requester={{id, username, first_name, last_name}} - /> - </View> - )} </> ); }; @@ -160,8 +156,6 @@ const styles = StyleSheet.create({ height: SCREEN_HEIGHT / 10, flex: 1, alignItems: 'center', - borderColor: 'red', - borderWidth: 2, }, avatarContainer: { marginLeft: '5%', @@ -191,9 +185,7 @@ const styles = StyleSheet.create({ width: 42, right: '5%', }, - buttonsContainer: { - - }, + buttonsContainer: {}, }); export default Notification; |