-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
BaseLocationErrorMessage.js
77 lines (70 loc) · 3.09 KB
/
BaseLocationErrorMessage.js
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
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import CONST from '../../CONST';
import colors from '../../styles/colors';
import styles from '../../styles/styles';
import Icon from '../Icon';
import * as Expensicons from '../Icon/Expensicons';
import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback';
import Text from '../Text';
import TextLink from '../TextLink';
import Tooltip from '../Tooltip';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import * as locationErrorMessagePropTypes from './locationErrorMessagePropTypes';
const propTypes = {
/** A callback that runs when 'allow location permission' link is pressed */
onAllowLocationLinkPress: PropTypes.func.isRequired,
// eslint-disable-next-line react/forbid-foreign-prop-types
...locationErrorMessagePropTypes.propTypes,
/* Onyx Props */
...withLocalizePropTypes,
};
function BaseLocationErrorMessage({onClose, onAllowLocationLinkPress, locationErrorCode, translate}) {
if (!locationErrorCode) {
return null;
}
const isPermissionDenied = locationErrorCode === 1;
return (
<View style={[styles.dotIndicatorMessage, styles.mt4]}>
<View style={styles.offlineFeedback.errorDot}>
<Icon
src={Expensicons.DotIndicator}
fill={colors.red}
/>
</View>
<View style={styles.offlineFeedback.textContainer}>
{isPermissionDenied ? (
<Text>
<Text style={[styles.offlineFeedback.text]}>{`${translate('location.permissionDenied')} ${translate('location.please')}`}</Text>
<TextLink
onPress={onAllowLocationLinkPress}
style={styles.locationErrorLinkText}
>
{` ${translate('location.allowPermission')} `}
</TextLink>
<Text style={[styles.offlineFeedback.text]}>{translate('location.tryAgain')}</Text>
</Text>
) : (
<Text style={styles.offlineFeedback.text}>{translate('location.notFound')}</Text>
)}
</View>
<View>
<Tooltip text={translate('common.close')}>
<PressableWithoutFeedback
onPress={onClose}
style={[styles.touchableButtonImage]}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
accessibilityLabel={translate('common.close')}
>
<Icon src={Expensicons.Close} />
</PressableWithoutFeedback>
</Tooltip>
</View>
</View>
);
}
BaseLocationErrorMessage.displayName = 'BaseLocationErrorMessage';
BaseLocationErrorMessage.propTypes = propTypes;
BaseLocationErrorMessage.defaultProps = locationErrorMessagePropTypes.defaultProps;
export default withLocalize(BaseLocationErrorMessage);