|
@@ -0,0 +1,61 @@
|
|
|
+import React from 'react';
|
|
|
+import { View, Text, TouchableOpacity } from 'react-native';
|
|
|
+import Modal from 'react-native-modal';
|
|
|
+import { useError } from 'src/contexts/ErrorContext';
|
|
|
+
|
|
|
+import { styles } from '../WarningModal/styles';
|
|
|
+import { Colors } from 'src/theme';
|
|
|
+
|
|
|
+import CloseIcon from 'assets/icons/close.svg';
|
|
|
+import { ButtonVariants } from 'src/types/components';
|
|
|
+import { Button } from '../Button';
|
|
|
+import { CommonActions, useNavigation } from '@react-navigation/native';
|
|
|
+import { NAVIGATION_PAGES } from 'src/types';
|
|
|
+
|
|
|
+export const ErrorModal = () => {
|
|
|
+ const { error, hideError } = useError();
|
|
|
+ const navigation = useNavigation();
|
|
|
+
|
|
|
+ const handleClose = () => {
|
|
|
+ navigation.dispatch(
|
|
|
+ CommonActions.reset({
|
|
|
+ index: 1,
|
|
|
+ routes: [{ name: NAVIGATION_PAGES.IN_APP_MAP_TAB }]
|
|
|
+ })
|
|
|
+ );
|
|
|
+ hideError();
|
|
|
+ };
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Modal isVisible={!!error}>
|
|
|
+ <View style={styles.centeredView}>
|
|
|
+ <View style={styles.modalView}>
|
|
|
+ <View style={{ alignSelf: 'flex-end' }}>
|
|
|
+ <TouchableOpacity onPress={handleClose}>
|
|
|
+ <CloseIcon fill={Colors.LIGHT_GRAY} />
|
|
|
+ </TouchableOpacity>
|
|
|
+ </View>
|
|
|
+ <View style={styles.modalContent}>
|
|
|
+ <Text style={styles.modalTitle}>Oops!</Text>
|
|
|
+ <Text style={styles.modalText}>An error occurred: {error}</Text>
|
|
|
+ <View style={styles.buttonContainer}>
|
|
|
+ <Button
|
|
|
+ variant={ButtonVariants.OPACITY}
|
|
|
+ containerStyles={{
|
|
|
+ borderColor: Colors.DARK_BLUE,
|
|
|
+ backgroundColor: Colors.DARK_BLUE,
|
|
|
+ width: '60%'
|
|
|
+ }}
|
|
|
+ textStyles={{
|
|
|
+ color: Colors.WHITE
|
|
|
+ }}
|
|
|
+ onPress={handleClose}
|
|
|
+ children="OK"
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </Modal>
|
|
|
+ );
|
|
|
+};
|