connect-transfer-react-native-sdk
Version:
Connect Transfer React Native SDK for Mastercard Open Banking Connect
80 lines (79 loc) • 2.74 kB
JavaScript
;
import { View, Text } from 'react-native';
import { useTranslation } from 'react-i18next';
import BottomSheet, { BottomSheetView } from '@gorhom/bottom-sheet';
import { useDispatch, useSelector } from 'react-redux';
import MACrossDismiss from './MACrossDismiss';
import MAButton from './MAButton';
import { MAExitBottomSheetStyle as styles } from './ComponentStyles';
import { ListenerType, RedirectReason, TransferActionEvents, API_KEYS } from '../constants';
import { useTransferEventResponse } from '../events/transferEventHandlers';
import { resetData } from '../redux/slices/authenticationSlice';
import { auditEvents } from '../services/api/auditEvents';
import { eventQueue, useSendAuditData } from '../events/auditEventQueue';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const MAExitBottomSheet = ({
bottomSheetRef,
onClose
}) => {
const dispatch = useDispatch();
const {
t
} = useTranslation();
const {
applicationName = ''
} = useSelector(state => state.user?.data?.data?.metadata || {});
const {
eventHandler: transferEventHandler
} = useSelector(state => state.event || {});
const {
getResponseForClose
} = useTransferEventResponse();
const sendAuditData = useSendAuditData();
const onExitPressed = () => {
transferEventHandler?.onTransferEnd(getResponseForClose(RedirectReason.EXIT));
sendAuditData(TransferActionEvents.END, {
reason: RedirectReason.EXIT,
listenerType: ListenerType.CLOSE
});
eventQueue.destroy();
dispatch(resetData());
};
const renderBackdropComponent = style => /*#__PURE__*/_jsx(View, {
style: [style, styles.backdrop],
testID: "bottom-sheet-backdrop"
});
return /*#__PURE__*/_jsx(BottomSheet, {
handleComponent: null,
ref: bottomSheetRef,
enablePanDownToClose: true,
backdropComponent: ({
style
}) => renderBackdropComponent(style),
children: /*#__PURE__*/_jsxs(BottomSheetView, {
style: styles.content,
children: [/*#__PURE__*/_jsx(MACrossDismiss, {
onCrossPress: onClose
}), /*#__PURE__*/_jsx(Text, {
style: styles.title,
children: t('ExitPopUpTitle')
}), /*#__PURE__*/_jsx(Text, {
style: styles.subtitle,
children: t('ExitPopUpSubtitle', {
applicationName
})
}), /*#__PURE__*/_jsx(MAButton, {
text: t('YesExit'),
style: styles.exitButton,
onPress: onExitPressed
}), /*#__PURE__*/_jsx(MAButton, {
text: t('NoStay'),
style: styles.stayButton,
textStyle: styles.stayButtonText,
onPress: onClose
})]
})
});
};
export default MAExitBottomSheet;
//# sourceMappingURL=MAExitBottomSheet.js.map