@automattic/jetpack-connection 0.30.7 → 0.30.8
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,10 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Connection Component releases.
|
|
4
4
|
|
|
5
|
+
## [0.30.8] - 2023-11-20
|
|
6
|
+
### Added
|
|
7
|
+
- Add optional quantity to product checkout workflow hook. [#34177]
|
|
8
|
+
|
|
5
9
|
## [0.30.7] - 2023-11-14
|
|
6
10
|
### Changed
|
|
7
11
|
- Updated package dependencies. [#34093]
|
|
@@ -660,6 +664,7 @@
|
|
|
660
664
|
- `Main` and `ConnectUser` components added.
|
|
661
665
|
- `JetpackRestApiClient` API client added.
|
|
662
666
|
|
|
667
|
+
[0.30.8]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.7...v0.30.8
|
|
663
668
|
[0.30.7]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.6...v0.30.7
|
|
664
669
|
[0.30.6]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.5...v0.30.6
|
|
665
670
|
[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
|
|
25
|
-
* @param {string} props.productSlug
|
|
26
|
-
* @param {string} props.redirectUrl
|
|
27
|
-
* @param {string} [props.siteSuffix]
|
|
28
|
-
* @param {string} [props.adminUrl]
|
|
29
|
-
* @param {boolean} props.connectAfterCheckout
|
|
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
|
|
32
|
-
* @
|
|
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
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.30.8",
|
|
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,10 +14,10 @@
|
|
|
14
14
|
"author": "Automattic",
|
|
15
15
|
"license": "GPL-2.0-or-later",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@automattic/jetpack-analytics": "^0.1.
|
|
18
|
-
"@automattic/jetpack-api": "^0.16.
|
|
19
|
-
"@automattic/jetpack-components": "^0.45.
|
|
20
|
-
"@automattic/jetpack-config": "^0.1.
|
|
17
|
+
"@automattic/jetpack-analytics": "^0.1.28",
|
|
18
|
+
"@automattic/jetpack-api": "^0.16.6",
|
|
19
|
+
"@automattic/jetpack-components": "^0.45.2",
|
|
20
|
+
"@automattic/jetpack-config": "^0.1.23",
|
|
21
21
|
"@wordpress/base-styles": "4.36.0",
|
|
22
22
|
"@wordpress/browserslist-config": "5.28.0",
|
|
23
23
|
"@wordpress/components": "25.11.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"prop-types": "^15.7.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
33
|
+
"@automattic/jetpack-base-styles": "^0.6.13",
|
|
34
34
|
"@babel/core": "7.23.2",
|
|
35
35
|
"@babel/preset-react": "7.22.15",
|
|
36
36
|
"@storybook/addon-actions": "7.4.6",
|