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/common/AcceptDeclineButtons.tsx | |
parent | df6595694c678657fec30d881fb1edcd39b62f17 (diff) |
fixes
Diffstat (limited to 'src/components/common/AcceptDeclineButtons.tsx')
-rw-r--r-- | src/components/common/AcceptDeclineButtons.tsx | 96 |
1 files changed, 51 insertions, 45 deletions
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<string, StyleProp<ViewStyle>>; } -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)); - }; +const AcceptDeclineButtons: React.FC<AcceptDeclineButtonsProps> = ({ + requester, + onAccept, + onReject, + externalStyles, +}) => { return ( - <> - <Button - title="Accept" - buttonStyle={styles.acceptButton} - titleStyle={styles.acceptButtonTitle} - onPress={() => handleAcceptRequest()} - /> - <Button - title="Reject" - buttonStyle={styles.rejectButton} - titleStyle={styles.rejectButtonTitle} - onPress={() => handleDeclineFriendRequest()} - /> - </> + <View style={[styles.container, externalStyles?.container]}> + <TouchableOpacity + style={[styles.genericButtonStyle, styles.acceptButton]} + onPress={onAccept}> + <Text style={[styles.buttonTitle, styles.acceptButtonTitleColor]}> + Accept + </Text> + </TouchableOpacity> + + <TouchableOpacity + style={[styles.genericButtonStyle, styles.rejectButton]} + onPress={onReject}> + <Text style={[styles.buttonTitle, styles.rejectButtonTitleColor]}> + Reject + </Text> + </TouchableOpacity> + </View> ); }; const styles = StyleSheet.create({ - acceptButton: { + container: { + flex: 1, + flexDirection: 'column', + }, + genericButtonStyle: { justifyContent: 'center', alignItems: 'center', width: SCREEN_WIDTH * 0.2, height: SCREEN_WIDTH * 0.07, borderRadius: 5, padding: 0, - marginRight: '2%', + marginTop: 10, + marginRight: '5%', + }, + acceptButton: { + padding: 0, 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', + borderColor: TAGG_TEXT_LIGHT_BLUE, }, - rejectButtonTitle: { + acceptButtonTitleColor: { + color: 'white', + }, + rejectButtonTitleColor: { color: TAGG_TEXT_LIGHT_BLUE, - padding: 0, - fontSize: 14, - fontWeight: '800', }, - acceptButtonTitle: { - color: 'white', + buttonTitle: { padding: 0, fontSize: 14, fontWeight: '800', |