aboutsummaryrefslogtreecommitdiff
path: root/src/components/notifications/Notification.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/notifications/Notification.tsx')
-rw-r--r--src/components/notifications/Notification.tsx46
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;