Skip to content

Commit

Permalink
Merge pull request #46269 from tienifr/fix/45431
Browse files Browse the repository at this point in the history
fix update settings button title in web
  • Loading branch information
Julesssss committed Aug 20, 2024
2 parents fd2c5f5 + 157bd5a commit 4e01691
Showing 1 changed file with 17 additions and 3 deletions.
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');
};

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

0 comments on commit 4e01691

Please sign in to comment.