Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/components/LocationPermissionModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import ConfirmModal from '@components/ConfirmModal';
import * as Illustrations from '@components/Icon/Illustrations';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import getPlatform from '@libs/getPlatform';
import {getLocationPermission, requestLocationPermission} from '@pages/iou/request/step/IOURequestStepScan/LocationPermission';
import CONST from '@src/CONST';
import type {LocationPermissionModalProps} from './types';

function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDeny, onGrant}: LocationPermissionModalProps) {
Expand All @@ -15,6 +17,8 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
const styles = useThemeStyles();
const {translate} = useLocalize();

const isWeb = getPlatform() === CONST.PLATFORM.WEB;

useEffect(() => {
if (!startPermissionFlow) {
return;
Expand All @@ -32,8 +36,10 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
}, [startPermissionFlow]);

const handledBlockedPermission = (cb: () => void) => () => {
if (hasError && Linking.openSettings) {
Linking.openSettings();
if (hasError) {
if (Linking.openSettings) {
Linking.openSettings();
}
setShowModal(false);
setHasError(false);
resetPermissionFlow();
Expand Down Expand Up @@ -63,12 +69,20 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
setHasError(false);
};

const getConfirmText = (): string => {
if (!hasError) {
return translate('common.continue');
}

return isWeb ? translate('common.buttonConfirm') : translate('common.settings');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about desktop? Aren't we supposed to use the "Got it" message as well?

};

return (
<ConfirmModal
isVisible={showModal}
onConfirm={grantLocationPermission}
onCancel={skipLocationPermission}
confirmText={hasError ? translate('common.settings') : translate('common.continue')}
confirmText={getConfirmText()}
cancelText={translate('common.notNow')}
prompt={translate(hasError ? 'receipt.locationErrorMessage' : 'receipt.locationAccessMessage')}
promptStyles={[styles.textLabelSupportingEmptyValue, styles.mb4]}
Expand Down