@shopgate/engage 7.30.0 → 7.30.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/a11y/reducers/index.js +1 -4
  2. package/account/reducers/index.js +2 -4
  3. package/app-rating/reducers/index.js +1 -1
  4. package/back-in-stock/reducers/index.js +1 -1
  5. package/cart/components/CartItem/CartItemProductLayoutWide.js +1 -1
  6. package/cart/components/CartItem/CartItemProductLayoutWide.style.js +1 -1
  7. package/checkout/paymentMethods/paypal/PaypalPayButton.js +1 -1
  8. package/checkout/paymentMethods/stripe/StripeButton.js +6 -2
  9. package/checkout/reducers/index.js +1 -3
  10. package/components/IntersectionVisibility/index.js +14 -9
  11. package/core/actions/getGeolocation.js +4 -4
  12. package/core/actions/grantAppTrackingTransparencyPermission.d.ts +24 -0
  13. package/core/actions/grantAppTrackingTransparencyPermission.js +18 -2
  14. package/core/actions/grantCameraPermissions.d.ts +24 -0
  15. package/core/actions/grantCameraPermissions.js +5 -2
  16. package/core/actions/grantGeolocationPermissions.d.ts +36 -0
  17. package/core/actions/grantGeolocationPermissions.js +18 -6
  18. package/core/actions/grantPermissions.d.ts +142 -0
  19. package/core/actions/grantPermissions.js +132 -18
  20. package/core/actions/grantPushPermissions.d.ts +24 -0
  21. package/core/actions/grantPushPermissions.js +9 -2
  22. package/core/actions/requestAppPermission.js +12 -3
  23. package/core/actions/requestAppPermissionStatus.js +2 -1
  24. package/core/config/config.reducers.js +1 -1
  25. package/core/config/config.selectors.js +6 -1
  26. package/core/constants/index.js +24 -1
  27. package/core/reducers/app.js +1 -4
  28. package/core/reducers/merchantSettings.js +1 -4
  29. package/core/reducers/shopSettings.js +3 -6
  30. package/core/router/permissionRouteRedirectHandler.js +117 -0
  31. package/core/subscriptions/app.js +10 -2
  32. package/development/reducers/settings.js +1 -3
  33. package/development/reducers/storage.js +1 -3
  34. package/filter/components/FilterPageContent/components/ResetButton/style.js +1 -1
  35. package/locations/components/FulfillmentSlotSwitcher/time.js +1 -1
  36. package/locations/reducers/storage.js +2 -6
  37. package/locations/reducers/storeFinderSearch.js +1 -5
  38. package/locations/reducers/user.js +1 -1
  39. package/locations/reducers/userFormInput.js +1 -1
  40. package/locations/reducers/userSearch.js +1 -1
  41. package/locations/selectors/index.js +21 -26
  42. package/orders/reducers/orders.js +4 -11
  43. package/orders/reducers/ordersById.js +4 -9
  44. package/orders/reducers/ordersByNumber.js +4 -9
  45. package/package.json +14 -13
  46. package/page/reducers/index.js +1 -5
  47. package/page/selectors/index.js +2 -1
  48. package/product/components/Description/style.js +1 -1
  49. package/product/components/EffectivityDates/index.js +3 -3
  50. package/product/components/FilterBar/mock.js +1 -1
  51. package/product/components/MapPriceHint/index.js +4 -4
  52. package/product/components/ProductList/components/Item/index.js +2 -5
  53. package/product/components/Swatch/Swatch.js +1 -1
  54. package/product/components/Swatch/VariantSwatch.js +1 -1
  55. package/product/components/Swatches/Swatches.js +1 -1
  56. package/product/selectors/product.js +6 -1
  57. package/push-opt-in/reducers/optInModal.js +1 -1
  58. package/push-opt-in/reducers/optInTrigger.js +1 -1
  59. package/tracking/reducers/cookieConsentModal.js +1 -1
  60. package/tracking/reducers/cookieSettings.js +1 -1
  61. package/tracking/selectors/cookieConsent.js +2 -1
  62. package/tracking/subscriptions/cookieConsent.js +3 -9
@@ -11,8 +11,7 @@ const defaultState = {
11
11
  * @param {Object} action The action object.
12
12
  * @returns {Object} The new state.
13
13
  */
14
- export default function a11y(state = defaultState, action) {
15
- /* eslint-disable no-param-reassign */
14
+ export default function a11y(state = defaultState, action = {}) {
16
15
  const producer = produce(draft => {
17
16
  switch (action.type) {
18
17
  case A11Y_INCREASE_MODAL_COUNT:
@@ -35,7 +34,5 @@ export default function a11y(state = defaultState, action) {
35
34
  break;
36
35
  }
37
36
  });
38
- /* eslint-enable no-param-reassign */
39
-
40
37
  return producer(state);
41
38
  }
@@ -1,6 +1,6 @@
1
1
  import { produce } from 'immer';
2
2
  import { SUCCESS_LOGOUT } from '@shopgate/engage/core/constants';
3
- import { FETCH_CUSTOMER_CONTACTS, FETCH_CUSTOMER_CONTACTS_SUCCESS, FETCH_CUSTOMER_CONTACTS_ERROR, FETCH_CUSTOMER, FETCH_CUSTOMER_SUCCESS, FETCH_CUSTOMER_ERROR } from "../constants/actions";
3
+ import { FETCH_CUSTOMER_CONTACTS, FETCH_CUSTOMER_CONTACTS_SUCCESS, FETCH_CUSTOMER_CONTACTS_ERROR, FETCH_CUSTOMER, FETCH_CUSTOMER_SUCCESS, FETCH_CUSTOMER_ERROR } from "../constants";
4
4
  const initialState = {
5
5
  customer: {
6
6
  isFetching: false,
@@ -18,8 +18,7 @@ const initialState = {
18
18
  * @param {Object} action The redux action.
19
19
  * @returns {Object}
20
20
  */
21
- export default function checkoutReducer(state = initialState, action) {
22
- /* eslint-disable no-param-reassign */
21
+ export default function checkoutReducer(state = initialState, action = {}) {
23
22
  const producer = produce(draft => {
24
23
  switch (action.type) {
25
24
  case FETCH_CUSTOMER_CONTACTS:
@@ -64,6 +63,5 @@ export default function checkoutReducer(state = initialState, action) {
64
63
  break;
65
64
  }
66
65
  });
67
- /* eslint-enable no-param-reassign */
68
66
  return producer(state);
69
67
  }
@@ -17,7 +17,7 @@ const defaultState = {
17
17
  * @param {Object} action The action object.
18
18
  * @return {Object} The new state.
19
19
  */
20
- export default (state = defaultState, action) => {
20
+ export default (state = defaultState, action = {}) => {
21
21
  switch (action.type) {
22
22
  case APP_RATING_INCREASE_APP_START_COUNT:
23
23
  {
@@ -12,7 +12,7 @@ const initialState = {
12
12
  * @param {Object} action The redux action.
13
13
  * @returns {Object}
14
14
  */
15
- export default (state = initialState, action) => {
15
+ export default (state = initialState, action = {}) => {
16
16
  switch (action.type) {
17
17
  case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS:
18
18
  {
@@ -1,4 +1,4 @@
1
- import React, { Fragment } from 'react';
1
+ import React from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { TextLink, ProductProperties, QuantityLabel, ConditionalWrapper, MessageBar, SurroundPortals } from '@shopgate/engage/components';
4
4
  import { ProductImage, CartUnitQuantityPicker, PriceInfo, ProductName, ITEM_PATH } from '@shopgate/engage/product';
@@ -15,7 +15,7 @@ export const imageColumn = css({
15
15
  marginRight: variables.gap.small,
16
16
  flexShrink: 0,
17
17
  flexGrow: 0
18
- });
18
+ }).toString();
19
19
  export const column = css({
20
20
  display: 'flex',
21
21
  alignItems: 'center',
@@ -1,4 +1,4 @@
1
- import React, { useLayoutEffect, useEffect, useRef, useState, Fragment } from 'react';
1
+ import React, { useLayoutEffect, useEffect, useRef, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { css } from 'glamor';
4
4
  import { getThemeSettings, showModal, MODAL_PIPELINE_ERROR } from '@shopgate/engage/core';
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState, Fragment } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { css } from 'glamor';
4
4
  import Button from "../../components/PaymentMethodButton";
@@ -16,8 +16,12 @@ const styles = {
16
16
  };
17
17
 
18
18
  /**
19
- * Stripe
19
+ * Stripe Payment Button Component
20
20
  * @param {Object} props Props
21
+ * @param {string} props.publishableKey Publishable Key
22
+ * @param {Function} props.onChange onChange handler
23
+ * @param {boolean} props.active Whether the method is active
24
+ * @param {Object} props.activePaymentMeta Active payment meta
21
25
  * @returns {JSX}
22
26
  */
23
27
  const StripeButton = ({
@@ -29,8 +29,7 @@ const initialState = {
29
29
  * @param {Object} action The redux action.
30
30
  * @returns {Object}
31
31
  */
32
- export default function checkoutReducer(state = initialState, action) {
33
- /* eslint-disable no-param-reassign */
32
+ export default function checkoutReducer(state = initialState, action = {}) {
34
33
  const producer = produce(draft => {
35
34
  switch (action.type) {
36
35
  case FETCH_CHECKOUT_ORDER:
@@ -88,6 +87,5 @@ export default function checkoutReducer(state = initialState, action) {
88
87
  break;
89
88
  }
90
89
  });
91
- /* eslint-enable no-param-reassign */
92
90
  return producer(state);
93
91
  }
@@ -14,14 +14,13 @@ import 'intersection-observer';
14
14
  * </IntersectionVisibility>
15
15
  */
16
16
  let IntersectionVisibility = /*#__PURE__*/function (_Component) {
17
- function IntersectionVisibility(...args) {
17
+ /**
18
+ * Initializes the component state.
19
+ * @param {Object} props The components props.
20
+ */
21
+ function IntersectionVisibility(props) {
18
22
  var _this;
19
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
20
- _this.state = {
21
- visible: true,
22
- ratio: 1,
23
- entries: null
24
- };
23
+ _this = _Component.call(this, props) || this;
25
24
  /**
26
25
  * @param {Object} ref ref
27
26
  */
@@ -47,13 +46,19 @@ let IntersectionVisibility = /*#__PURE__*/function (_Component) {
47
46
  entries
48
47
  });
49
48
  };
49
+ _this.state = {
50
+ visible: true,
51
+ ratio: 1,
52
+ entries: null
53
+ };
50
54
  return _this;
51
55
  }
52
- _inheritsLoose(IntersectionVisibility, _Component);
53
- var _proto = IntersectionVisibility.prototype;
56
+
54
57
  /**
55
58
  * Start the observer when the component is mounted
56
59
  */
60
+ _inheritsLoose(IntersectionVisibility, _Component);
61
+ var _proto = IntersectionVisibility.prototype;
57
62
  _proto.componentDidMount = function componentDidMount() {
58
63
  this.io = new IntersectionObserver(this.handleIntersectionEvent, {
59
64
  threshold: this.props.thresholds
@@ -18,15 +18,15 @@ import GeolocationRequest from "../classes/GeolocationRequest";
18
18
  * @return { Function } A redux thunk.
19
19
  */
20
20
  const getGeolocation = (options = {}) => async dispatch => {
21
- const granted = await dispatch(grantGeolocationPermissions({
21
+ const result = await dispatch(grantGeolocationPermissions({
22
22
  resolveWithData: true,
23
23
  ...options
24
24
  }));
25
- if (typeof granted === 'object') {
25
+ if (result?.data) {
26
26
  // Other than the app, within browsers we might already have a geolocation.
27
- return Promise.resolve(granted);
27
+ return Promise.resolve(result.data);
28
28
  }
29
- if (!granted) {
29
+ if (!result.success) {
30
30
  const error = new Error('Geolocation permissions not granted.');
31
31
  error.code = GEOLOCATION_ERROR_DENIED;
32
32
  throw error;
@@ -0,0 +1,24 @@
1
+ import type { UnknownAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+
4
+ export type { GrantPermissionsOptions, GrantPermissionsResult } from './grantPermissions';
5
+ export type { GrantPermissionsOptions, GrantPermissionsResult };
6
+
7
+ /**
8
+ * Determines the current state of the app tracking transparency permissions.
9
+ * If not already happened, the user will be prompted to grant permissions.
10
+ *
11
+ * The action returns a promise which resolves with a boolean value, that indicates the state.
12
+ *
13
+ * When the "resolveWithData" option is set to TRUE, the promise will resolve with an object
14
+ * containing the permission status and additional data, instead of a boolean value.
15
+ */
16
+ declare function grantAppTrackingTransparencyPermission<State = unknown>(
17
+ options: Omit<GrantPermissionsOptions, 'permissionId'> & { resolveWithData: true }
18
+ ): ThunkAction<Promise<GrantPermissionsResult>, State, unknown, UnknownAction>;
19
+
20
+ declare function grantAppTrackingTransparencyPermission<State = unknown>(
21
+ options?: Omit<GrantPermissionsOptions, 'permissionId'> & { resolveWithData?: false | undefined }
22
+ ): ThunkAction<Promise<boolean>, State, unknown, UnknownAction>;
23
+
24
+ export default grantAppTrackingTransparencyPermission;
@@ -7,15 +7,31 @@ import grantPermissions from "./grantPermissions";
7
7
  * The action returns a promise which resolves with a boolean value, that indicates the state.
8
8
  * @param {Object} options Action options.
9
9
  * @param {Object} [options.meta={}] Additional meta data used for opt-in tracking actions
10
+ * @param {Object} [options.modal={}] Options for the settings modal.
11
+ * @param {string} options.modal.title Modal title.
12
+ * @param {string} options.modal.message Modal message.
13
+ * @param {string} options.modal.confirm Label for the confirm button.
14
+ * @param {string} options.modal.dismiss Label for the dismiss button.
15
+ * @param {Object} options.modal.params Additional parameters for i18n strings.
10
16
  * @return { Function } A redux thunk.
11
17
  */
12
18
  const grantAppTrackingTransparencyPermission = (options = {}) => dispatch => {
13
19
  const {
14
- meta = {}
20
+ permissionId,
21
+ meta = {},
22
+ modal = {},
23
+ ...rest
15
24
  } = options;
16
25
  return dispatch(grantPermissions({
17
26
  permissionId: PERMISSION_ID_APP_TRACKING_TRANSPARENCY,
18
- meta
27
+ meta,
28
+ modal: {
29
+ message: 'permissions.access_denied.trackingMessage',
30
+ confirm: 'permissions.access_denied.settings_button',
31
+ dismiss: 'modal.dismiss',
32
+ ...modal
33
+ },
34
+ ...rest
19
35
  }));
20
36
  };
21
37
  export default grantAppTrackingTransparencyPermission;
@@ -0,0 +1,24 @@
1
+ import type { UnknownAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+
4
+ export type { GrantPermissionsOptions, GrantPermissionsResult } from './grantPermissions';
5
+ export type { GrantPermissionsOptions, GrantPermissionsResult };
6
+
7
+ /**
8
+ * Determines the current state of the camera permissions.
9
+ * If not already happened, the user will be prompted to grant permissions.
10
+ *
11
+ * The action returns a promise which resolves with a boolean value, that indicates the state.
12
+ *
13
+ * When the "resolveWithData" option is set to TRUE, the promise will resolve with an object
14
+ * containing the permission status and additional data, instead of a boolean value.
15
+ */
16
+ declare function grantCameraPermissions<State = unknown>(
17
+ options: Omit<GrantPermissionsOptions, 'permissionId'> & { resolveWithData: true }
18
+ ): ThunkAction<Promise<GrantPermissionsResult>, State, unknown, UnknownAction>;
19
+
20
+ declare function grantCameraPermissions<State = unknown>(
21
+ options?: Omit<GrantPermissionsOptions, 'permissionId'> & { resolveWithData?: false | undefined }
22
+ ): ThunkAction<Promise<boolean>, State, unknown, UnknownAction>;
23
+
24
+ export default grantCameraPermissions;
@@ -18,8 +18,10 @@ import grantPermissions from "./grantPermissions";
18
18
  */
19
19
  const grantCameraPermissions = (options = {}) => dispatch => {
20
20
  const {
21
+ permissionId,
21
22
  useSettingsModal = false,
22
- modal = {}
23
+ modal = {},
24
+ ...rest
23
25
  } = options;
24
26
  return dispatch(grantPermissions({
25
27
  permissionId: PERMISSION_ID_CAMERA,
@@ -30,7 +32,8 @@ const grantCameraPermissions = (options = {}) => dispatch => {
30
32
  confirm: 'permissions.access_denied.settings_button',
31
33
  dismiss: 'common.close',
32
34
  ...modal
33
- }
35
+ },
36
+ ...rest
34
37
  }));
35
38
  };
36
39
  export default grantCameraPermissions;
@@ -0,0 +1,36 @@
1
+ import type { UnknownAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+
4
+ import type { GrantPermissionsOptions, GrantPermissionsResult } from './grantPermissions';
5
+ export type { GrantPermissionsOptions, GrantPermissionsResult };
6
+
7
+ type GeolocationOptions = {
8
+ /**
9
+ * Whether to request background location access.
10
+ *
11
+ * **Note:** Since background location access will cause extended reviews by Google and Apple,
12
+ * this feature needs to be explicitly enabled by Shopgate.
13
+ */
14
+ requireBackgroundAccess?: boolean;
15
+ }
16
+
17
+ type GeolocationGrantOptions = Omit<GrantPermissionsOptions, 'permissionId'> & GeolocationOptions;
18
+
19
+ /**
20
+ * Determines the current state of the geolocation permissions.
21
+ * If not already happened, the user will be prompted to grant permissions.
22
+ *
23
+ * The action returns a promise which resolves with a boolean value, that indicates the state.
24
+ *
25
+ * When the "resolveWithData" option is set to TRUE, the promise will resolve with an object
26
+ * containing the permission status and additional data, instead of a boolean value.
27
+ */
28
+ declare function grantGeolocationPermissions<State = unknown>(
29
+ options: GeolocationGrantOptions & { resolveWithData: true }
30
+ ): ThunkAction<Promise<GrantPermissionsResult>, State, unknown, UnknownAction>;
31
+
32
+ declare function grantGeolocationPermissions<State = unknown>(
33
+ options?: GeolocationGrantOptions & { resolveWithData?: false | undefined }
34
+ ): ThunkAction<Promise<boolean>, State, unknown, UnknownAction>;
35
+
36
+ export default grantGeolocationPermissions;
@@ -1,4 +1,4 @@
1
- import { PERMISSION_ID_LOCATION } from '@shopgate/engage/core/constants';
1
+ import { PERMISSION_ID_LOCATION, PERMISSION_USAGE_ALWAYS } from '@shopgate/engage/core/constants';
2
2
  import { hasWebBridge } from '@shopgate/engage/core';
3
3
  import grantPermissions from "./grantPermissions";
4
4
 
@@ -7,12 +7,15 @@ import grantPermissions from "./grantPermissions";
7
7
  * If not already happened, the user will be prompted to grant permissions.
8
8
  * The action returns a promise which resolves with a boolean value, that indicates the state.
9
9
  * @param {Object} options Action options.
10
+ * @param {boolean} [options.requireBackgroundAccess=false] When set to TRUE, the action will
11
+ * attempt to request background location permissions,
10
12
  * @param {boolean} [options.useSettingsModal=false] Whether in case of declined permissions a modal
11
13
  * shall be presented, which redirects to the app settings.
12
14
  * @param {boolean} [options.requestPermissions=true] When set to TRUE the logic will not
13
15
  * attempt to request permissions, if they are not granted or determined yet.
14
- * @param {boolean} [options.resolveWithData=false] If set to TRUE, the promise will resolve
15
- * with data if available.
16
+ * @param {boolean} [options.resolveWithData=true] When set to TRUE the promise will resolve with
17
+ * an object containing the permission status and whether the opt-in dialog was shown,
18
+ * instead of a boolean value.
16
19
  * @param {Object} [options.modal={}] Options for the settings modal.
17
20
  * @param {string} options.modal.title Modal title.
18
21
  * @param {string} options.modal.message Modal message.
@@ -23,23 +26,32 @@ import grantPermissions from "./grantPermissions";
23
26
  */
24
27
  const grantGeolocationPermissions = (options = {}) => dispatch => {
25
28
  const {
29
+ permissionId,
26
30
  useSettingsModal = false,
27
31
  modal = {},
28
32
  requestPermissions = true,
29
- resolveWithData = false
33
+ resolveWithData = false,
34
+ requireBackgroundAccess = false,
35
+ ...rest
30
36
  } = options;
31
37
  return dispatch(grantPermissions({
32
38
  permissionId: PERMISSION_ID_LOCATION,
39
+ ...(requireBackgroundAccess ? {
40
+ permissionOptions: {
41
+ usage: PERMISSION_USAGE_ALWAYS
42
+ }
43
+ } : {}),
33
44
  requestPermissions,
34
45
  resolveWithData,
35
46
  useSettingsModal,
36
47
  modal: {
37
48
  title: null,
38
- message: 'permissions.access_denied.geolocation_message',
49
+ message: `permissions.access_denied.${requireBackgroundAccess ? 'geolocationMessageBackground' : 'geolocation_message'}`,
39
50
  confirm: !hasWebBridge() ? 'permissions.access_denied.settings_button' : null,
40
51
  dismiss: 'modal.dismiss',
41
52
  ...modal
42
- }
53
+ },
54
+ ...rest
43
55
  }));
44
56
  };
45
57
  export default grantGeolocationPermissions;
@@ -0,0 +1,142 @@
1
+ import type { UnknownAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+
4
+ type PermissionStatus =
5
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_STATUS_NOT_DETERMINED
6
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_STATUS_DENIED
7
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_STATUS_GRANTED
8
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_STATUS_NOT_SUPPORTED
9
+
10
+ type PermissionId =
11
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_ID_LOCATION
12
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_ID_BACKGROUND_LOCATION
13
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_ID_CAMERA
14
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_ID_PUSH
15
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_ID_APP_TRACKING_TRANSPARENCY
16
+
17
+ type PermissionUsage =
18
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_USAGE_ALWAYS
19
+ | typeof import('@shopgate/engage/core/constants').PERMISSION_USAGE_WHEN_IN_USE
20
+
21
+ export interface PermissionMeta {
22
+ permission: 'push' | 'location' | 'backgroundLocation' | 'camera' | 'tracking' ;
23
+ context: string;
24
+ contextCounter?: number;
25
+ usesSoftPushOptIn?: boolean;
26
+ usesSoftTrackingOptIn?: boolean;
27
+ }
28
+
29
+ export interface PermissionModalOptions {
30
+ /**
31
+ * Modal title.
32
+ */
33
+ title?: string | null;
34
+ /**
35
+ * Modal message.
36
+ */
37
+ message?: string;
38
+ /**
39
+ * Label for the confirm button.
40
+ */
41
+ confirm?: string;
42
+ /**
43
+ * Label for the dismiss button.
44
+ */
45
+ dismiss?: string;
46
+ /**
47
+ * Additional parameters for i18n strings.
48
+ */
49
+ params?: Record<string, unknown>;
50
+ }
51
+
52
+ export interface GrantPermissionsOptions {
53
+ /**
54
+ * The id of the permission to request.
55
+ */
56
+ permissionId: PermissionId;
57
+
58
+ /**
59
+ * Additional options for the permission request (forwarded to native).
60
+ */
61
+ permissionOptions?: Record<string, unknown>;
62
+
63
+ /**
64
+ * Whether in case of declined permissions a modal shall redirect to app settings.
65
+ * Options for the settings modal can be set via `modal` property.
66
+ */
67
+ useSettingsModal?: boolean;
68
+
69
+ /**
70
+ * Whether a rationale modal should be shown before requesting the permission.
71
+ * Options for the rationale modal can be set via `rationaleModal` property.
72
+ */
73
+ useRationaleModal?: boolean;
74
+
75
+ /**
76
+ * Options for the rationale modal.
77
+ */
78
+ rationaleModal?: PermissionModalOptions;
79
+
80
+ /**
81
+ * Options for the settings modal.
82
+ */
83
+ modal?: PermissionModalOptions;
84
+
85
+ /**
86
+ * If TRUE, no permissions will be requested if not already granted.
87
+ * (I.e. only check status.)
88
+ */
89
+ requestPermissions?: boolean;
90
+
91
+ /**
92
+ * If TRUE, resolves with a data object instead of a boolean.
93
+ * Note: your JS default currently sets `resolveWithData = false`.
94
+ */
95
+ resolveWithData?: boolean;
96
+
97
+ /**
98
+ * Meta data used for opt-in tracking actions.
99
+ */
100
+ meta?: PermissionMeta & Record<string, unknown>;
101
+ }
102
+
103
+ export interface GrantPermissionsResult {
104
+ /**
105
+ * Whether the permission is granted after the action has been processed.
106
+ */
107
+ success: boolean;
108
+ /**
109
+ * The current status of the permission after the action has been processed.
110
+ */
111
+ status?: PermissionStatus;
112
+ /**
113
+ * Whether the user was prompted to grant permissions during the process.
114
+ */
115
+ optInRequested: boolean;
116
+ /**
117
+ * Additional options for the permission, e.g. usage (forwarded from native).
118
+ */
119
+ options?: {
120
+ usage: PermissionUsage;
121
+ };
122
+ /**
123
+ * Might be set when PWA runs in browser mode. In that cause it can contain resolved
124
+ * location data.
125
+ */
126
+ data?: unknown;
127
+ }
128
+
129
+ /**
130
+ * Determines the current state of a specific permission for an app feature. If not already
131
+ * happened, the user will be prompted to grant permissions.
132
+ *
133
+ * The action returns a promise which resolves with a boolean value, that indicates the state.
134
+ *
135
+ * When the "resolveWithData" option is set to TRUE, the promise will resolve with an object
136
+ * containing the permission status and additional data, instead of a boolean value.
137
+ */
138
+ declare function grantPermissions<State = unknown>(
139
+ options: GrantPermissionsOptions
140
+ ): ThunkAction<Promise<GrantPermissionsResult|boolean>, State, unknown, UnknownAction>;
141
+
142
+ export default grantPermissions;