@graphcommerce/magento-cart-payment-method 3.6.7 → 3.6.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 +23 -0
- package/hooks/useCartLock.ts +21 -7
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.6.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1692](https://github.com/graphcommerce-org/graphcommerce/pull/1692) [`a7fbe58d4`](https://github.com/graphcommerce-org/graphcommerce/commit/a7fbe58d4bbb43c59fa2ead05935757d2013404c) Thanks [@paales](https://github.com/paales)! - Make sure the cartLock state is refreshed when the page is loaded with the bfcache
|
|
8
|
+
|
|
9
|
+
- [#1692](https://github.com/graphcommerce-org/graphcommerce/pull/1692) [`edbecfbfd`](https://github.com/graphcommerce-org/graphcommerce/commit/edbecfbfd532a6c78ae75ffe850c4bcf898e855d) Thanks [@paales](https://github.com/paales)! - Locking the cart when navigating away from the checkout and unlock the cart when pressing back. Made the justLocked flag a global state.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`a26a2d05e`](https://github.com/graphcommerce-org/graphcommerce/commit/a26a2d05eecabeeef70e4d69105343197ae092b7)]:
|
|
12
|
+
- @graphcommerce/magento-cart@4.9.5
|
|
13
|
+
|
|
14
|
+
## 3.6.8
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#1688](https://github.com/graphcommerce-org/graphcommerce/pull/1688) [`f544401c7`](https://github.com/graphcommerce-org/graphcommerce/commit/f544401c7b653fda39c7c260ad0dcfb3bf543b65) Thanks [@paales](https://github.com/paales)! - Return the promise when changing the URL
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`8393cb266`](https://github.com/graphcommerce-org/graphcommerce/commit/8393cb2662860be0c2aa5df432447bb73c427d8e), [`f544401c7`](https://github.com/graphcommerce-org/graphcommerce/commit/f544401c7b653fda39c7c260ad0dcfb3bf543b65), [`f105d4223`](https://github.com/graphcommerce-org/graphcommerce/commit/f105d4223aa68df30970149e51ae72897e489bf9)]:
|
|
21
|
+
- @graphcommerce/next-ui@4.29.3
|
|
22
|
+
- @graphcommerce/framer-scroller@2.1.45
|
|
23
|
+
- @graphcommerce/magento-cart@4.9.4
|
|
24
|
+
- @graphcommerce/magento-store@4.3.6
|
|
25
|
+
|
|
3
26
|
## 3.6.7
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/hooks/useCartLock.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCurrentCartId } from '@graphcommerce/magento-cart'
|
|
2
2
|
import { useUrlQuery } from '@graphcommerce/next-ui'
|
|
3
|
-
import { useState } from 'react'
|
|
3
|
+
import { useEffect, useState } from 'react'
|
|
4
4
|
|
|
5
5
|
export type CartLockState = {
|
|
6
6
|
cart_id: string | null
|
|
@@ -8,6 +8,8 @@ export type CartLockState = {
|
|
|
8
8
|
method: string | null
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
let justLocked = false
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* Locking a cart might is usefull in the following cases: We want to disable cart modifications
|
|
13
15
|
* while still keeping the cart active on the website.
|
|
@@ -16,21 +18,33 @@ export type CartLockState = {
|
|
|
16
18
|
*/
|
|
17
19
|
export function useCartLock<E extends CartLockState>() {
|
|
18
20
|
const { currentCartId } = useCurrentCartId()
|
|
19
|
-
const [justLocked, setJustLocked] = useState(false)
|
|
20
21
|
const [queryState, setRouterQuery] = useUrlQuery<E>()
|
|
22
|
+
const [, setForceRender] = useState(0)
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const pageshow = (e: PageTransitionEvent) => {
|
|
26
|
+
if (!e.persisted) return
|
|
27
|
+
justLocked = false
|
|
28
|
+
setForceRender((cnt) => cnt + 1)
|
|
29
|
+
}
|
|
30
|
+
window.addEventListener('pageshow', pageshow)
|
|
31
|
+
return () => {
|
|
32
|
+
window.removeEventListener('pageshow', pageshow)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
21
35
|
|
|
22
36
|
const lock = (params: Omit<E, 'locked' | 'cart_id'>) => {
|
|
23
|
-
if (!currentCartId) return
|
|
24
|
-
|
|
25
|
-
setRouterQuery({
|
|
37
|
+
if (!currentCartId) return undefined
|
|
38
|
+
justLocked = true
|
|
39
|
+
return setRouterQuery({
|
|
26
40
|
locked: '1',
|
|
27
41
|
cart_id: currentCartId,
|
|
28
42
|
...params,
|
|
29
43
|
} as unknown as E)
|
|
30
44
|
}
|
|
31
45
|
|
|
32
|
-
const unlock = (params: Omit<E, 'locked' | 'cart_id' | 'method'>) => {
|
|
33
|
-
setRouterQuery({ cart_id: null, locked: null, method: null, ...params } as E)
|
|
46
|
+
const unlock = async (params: Omit<E, 'locked' | 'cart_id' | 'method'>) => {
|
|
47
|
+
await setRouterQuery({ cart_id: null, locked: null, method: null, ...params } as E)
|
|
34
48
|
return queryState
|
|
35
49
|
}
|
|
36
50
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-cart-payment-method",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "3.6.
|
|
5
|
+
"version": "3.6.9",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"@graphcommerce/eslint-config-pwa": "^4.1.10",
|
|
16
16
|
"@graphcommerce/prettier-config-pwa": "^4.0.6",
|
|
17
17
|
"@graphcommerce/typescript-config-pwa": "^4.0.4",
|
|
18
|
-
"@graphcommerce/magento-cart-shipping-address": "3.5.
|
|
18
|
+
"@graphcommerce/magento-cart-shipping-address": "3.5.9",
|
|
19
19
|
"@playwright/test": "^1.21.1",
|
|
20
20
|
"type-fest": "^2.12.2"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@graphcommerce/framer-scroller": "2.1.
|
|
23
|
+
"@graphcommerce/framer-scroller": "2.1.45",
|
|
24
24
|
"@graphcommerce/graphql": "3.5.0",
|
|
25
25
|
"@graphcommerce/image": "3.1.10",
|
|
26
|
-
"@graphcommerce/magento-cart": "4.9.
|
|
27
|
-
"@graphcommerce/magento-store": "4.3.
|
|
28
|
-
"@graphcommerce/next-ui": "4.29.
|
|
26
|
+
"@graphcommerce/magento-cart": "4.9.5",
|
|
27
|
+
"@graphcommerce/magento-store": "4.3.6",
|
|
28
|
+
"@graphcommerce/next-ui": "4.29.3",
|
|
29
29
|
"@graphcommerce/react-hook-form": "3.3.5"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|