1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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<AcceptDeclineButtonsProps> = (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 (
<>
<Button
title="Accept"
buttonStyle={styles.acceptButton}
titleStyle={styles.acceptButtonTitle}
onPress={() => handleAcceptRequest()}
/>
<Button
title="Reject"
buttonStyle={styles.rejectButton}
titleStyle={styles.rejectButtonTitle}
onPress={() => handleDeclineFriendRequest()}
/>
</>
);
};
const styles = StyleSheet.create({
acceptButton: {
justifyContent: 'center',
alignItems: 'center',
width: SCREEN_WIDTH * 0.2,
height: SCREEN_WIDTH * 0.07,
borderRadius: 5,
padding: 0,
marginRight: '2%',
backgroundColor: TAGG_TEXT_LIGHT_BLUE,
},
rejectButton: {
justifyContent: 'center',
alignItems: 'center',
width: SCREEN_WIDTH * 0.2,
height: SCREEN_WIDTH * 0.07,
borderColor: TAGG_TEXT_LIGHT_BLUE,
borderWidth: 1,
borderRadius: 5,
marginRight: '2%',
padding: 0,
backgroundColor: 'white',
},
rejectButtonTitle: {
color: TAGG_TEXT_LIGHT_BLUE,
padding: 0,
fontSize: 14,
fontWeight: '800',
},
acceptButtonTitle: {
color: 'white',
padding: 0,
fontSize: 14,
fontWeight: '800',
},
});
export default AcceptDeclineButtons;
|