@automattic/jetpack-connection 0.30.7 → 0.30.9

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Connection Component releases.
4
4
 
5
+ ## [0.30.9] - 2023-12-03
6
+ ### Changed
7
+ - Updated package dependencies. [#34411] [#34427]
8
+
9
+ ## [0.30.8] - 2023-11-20
10
+ ### Added
11
+ - Add optional quantity to product checkout workflow hook. [#34177]
12
+
5
13
  ## [0.30.7] - 2023-11-14
6
14
  ### Changed
7
15
  - Updated package dependencies. [#34093]
@@ -660,6 +668,8 @@
660
668
  - `Main` and `ConnectUser` components added.
661
669
  - `JetpackRestApiClient` API client added.
662
670
 
671
+ [0.30.9]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.8...v0.30.9
672
+ [0.30.8]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.7...v0.30.8
663
673
  [0.30.7]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.6...v0.30.7
664
674
  [0.30.6]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.5...v0.30.6
665
675
  [0.30.5]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.4...v0.30.5
@@ -21,15 +21,16 @@ const defaultAdminUrl =
21
21
  * Custom hook that performs the needed steps
22
22
  * to concrete the checkout workflow.
23
23
  *
24
- * @param {object} props - The props passed to the hook.
25
- * @param {string} props.productSlug - The WordPress product slug.
26
- * @param {string} props.redirectUrl - The URI to redirect to after checkout.
27
- * @param {string} [props.siteSuffix] - The site suffix.
28
- * @param {string} [props.adminUrl] - The site wp-admin url.
29
- * @param {boolean} props.connectAfterCheckout - Whether or not to conect after checkout if not connected (default false - connect before).
24
+ * @param {object} props - The props passed to the hook.
25
+ * @param {string} props.productSlug - The WordPress product slug.
26
+ * @param {string} props.redirectUrl - The URI to redirect to after checkout.
27
+ * @param {string} [props.siteSuffix] - The site suffix.
28
+ * @param {string} [props.adminUrl] - The site wp-admin url.
29
+ * @param {boolean} props.connectAfterCheckout - Whether or not to conect after checkout if not connected (default false - connect before).
30
30
  * @param {Function} props.siteProductAvailabilityHandler - The function used to check whether the site already has the requested product. This will be checked after registration and the checkout page will be skipped if the promise returned resloves true.
31
- * @param {Function} props.from - The plugin slug initiated the flow.
32
- * @returns {Function} - The useEffect hook.
31
+ * @param {Function} props.from - The plugin slug initiated the flow.
32
+ * @param {number} [props.quantity] - The quantity of the product to purchase.
33
+ * @returns {Function} The useEffect hook.
33
34
  */
34
35
  export default function useProductCheckoutWorkflow( {
35
36
  productSlug,
@@ -38,6 +39,7 @@ export default function useProductCheckoutWorkflow( {
38
39
  adminUrl = defaultAdminUrl,
39
40
  connectAfterCheckout = false,
40
41
  siteProductAvailabilityHandler = null,
42
+ quantity = null,
41
43
  from,
42
44
  } = {} ) {
43
45
  debug( 'productSlug is %s', productSlug );
@@ -61,7 +63,11 @@ export default function useProductCheckoutWorkflow( {
61
63
  ? 'checkout/jetpack/'
62
64
  : `checkout/${ siteSuffix }/`;
63
65
 
64
- const productCheckoutUrl = new URL( `${ origin }${ checkoutPath }${ productSlug }` );
66
+ const quantitySuffix = quantity != null ? `:-q-${ quantity }` : '';
67
+
68
+ const productCheckoutUrl = new URL(
69
+ `${ origin }${ checkoutPath }${ productSlug }${ quantitySuffix }`
70
+ );
65
71
 
66
72
  if ( shouldConnectAfterCheckout ) {
67
73
  productCheckoutUrl.searchParams.set( 'connect_after_checkout', true );
@@ -87,14 +93,15 @@ export default function useProductCheckoutWorkflow( {
87
93
 
88
94
  return productCheckoutUrl;
89
95
  }, [
90
- connectAfterCheckout,
91
96
  isRegistered,
97
+ isUserConnected,
98
+ connectAfterCheckout,
92
99
  siteSuffix,
100
+ quantity,
93
101
  productSlug,
94
- adminUrl,
95
102
  from,
96
103
  redirectUrl,
97
- isUserConnected,
104
+ adminUrl,
98
105
  ] );
99
106
 
100
107
  debug( 'isRegistered is %s', isRegistered );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-connection",
3
- "version": "0.30.7",
3
+ "version": "0.30.9",
4
4
  "description": "Jetpack Connection Component",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/connection/#readme",
6
6
  "bugs": {
@@ -14,31 +14,31 @@
14
14
  "author": "Automattic",
15
15
  "license": "GPL-2.0-or-later",
16
16
  "dependencies": {
17
- "@automattic/jetpack-analytics": "^0.1.27",
18
- "@automattic/jetpack-api": "^0.16.5",
19
- "@automattic/jetpack-components": "^0.45.1",
20
- "@automattic/jetpack-config": "^0.1.22",
21
- "@wordpress/base-styles": "4.36.0",
22
- "@wordpress/browserslist-config": "5.28.0",
23
- "@wordpress/components": "25.11.0",
24
- "@wordpress/data": "9.15.0",
25
- "@wordpress/element": "5.22.0",
26
- "@wordpress/i18n": "4.45.0",
27
- "@wordpress/icons": "9.36.0",
17
+ "@automattic/jetpack-analytics": "^0.1.29",
18
+ "@automattic/jetpack-api": "^0.16.7",
19
+ "@automattic/jetpack-components": "^0.45.4",
20
+ "@automattic/jetpack-config": "^0.1.24",
21
+ "@wordpress/base-styles": "4.38.0",
22
+ "@wordpress/browserslist-config": "5.30.0",
23
+ "@wordpress/components": "25.13.0",
24
+ "@wordpress/data": "9.17.0",
25
+ "@wordpress/element": "5.24.0",
26
+ "@wordpress/i18n": "4.47.0",
27
+ "@wordpress/icons": "9.38.0",
28
28
  "classnames": "2.3.2",
29
29
  "debug": "4.3.4",
30
30
  "prop-types": "^15.7.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@automattic/jetpack-base-styles": "^0.6.12",
33
+ "@automattic/jetpack-base-styles": "^0.6.14",
34
34
  "@babel/core": "7.23.2",
35
35
  "@babel/preset-react": "7.22.15",
36
36
  "@storybook/addon-actions": "7.4.6",
37
- "@testing-library/dom": "8.19.1",
37
+ "@testing-library/dom": "8.20.1",
38
38
  "@testing-library/react": "13.4.0",
39
- "@testing-library/user-event": "14.4.3",
40
- "jest": "29.4.3",
41
- "jest-environment-jsdom": "29.4.3",
39
+ "@testing-library/user-event": "14.5.1",
40
+ "jest": "29.7.0",
41
+ "jest-environment-jsdom": "29.7.0",
42
42
  "react": "18.2.0",
43
43
  "react-dom": "18.2.0",
44
44
  "react-test-renderer": "18.2.0"