@shopgate/engage
Version:
Shopgate's ENGAGE library.
19 lines • 2.65 kB
JavaScript
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_LOCATION}from'@shopgate/engage/core/constants';import{hasWebBridge}from'@shopgate/engage/core';import grantPermissions from"./grantPermissions";/**
* Determines the current state of the geolocation permissions.
* If not already happened, the user will be prompted to grant permissions.
* The action returns a promise which resolves with a boolean value, that indicates the state.
* @param {Object} options Action options.
* @param {boolean} [options.useSettingsModal=false] Whether in case of declined permissions a modal
* shall be presented, which redirects to the app settings.
* @param {boolean} [options.requestPermissions=true] When set to TRUE the logic will not
* attempt to request permissions, if they are not granted or determined yet.
* @param {boolean} [options.resolveWithData=false] If set to TRUE, the promise will resolve
* with data if available.
* @param {Object} [options.modal={}] Options for the settings modal.
* @param {string} options.modal.title Modal title.
* @param {string} options.modal.message Modal message.
* @param {string} options.modal.confirm Label for the confirm button.
* @param {string} options.modal.dismiss Label for the dismiss button.
* @param {Object} options.modal.params Additional parameters for i18n strings.
* @return { Function } A redux thunk.
*/var grantGeolocationPermissions=function grantGeolocationPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$modal=options.modal,modal=_options$modal===void 0?{}:_options$modal,_options$requestPermi=options.requestPermissions,requestPermissions=_options$requestPermi===void 0?true:_options$requestPermi,_options$resolveWithD=options.resolveWithData,resolveWithData=_options$resolveWithD===void 0?false:_options$resolveWithD;return dispatch(grantPermissions({permissionId:PERMISSION_ID_LOCATION,requestPermissions:requestPermissions,resolveWithData:resolveWithData,useSettingsModal:useSettingsModal,modal:_extends({title:null,message:'permissions.access_denied.geolocation_message',confirm:!hasWebBridge()?'permissions.access_denied.settings_button':null,dismiss:'modal.dismiss'},modal)}));};};export default grantGeolocationPermissions;