@graphcommerce/magento-cart-payment-method 8.0.3-canary.4 → 8.1.0-canary.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.
- package/CHANGELOG.md +1 -5
- package/hooks/useCartLock.ts +3 -7
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
package/hooks/useCartLock.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cartLock, useCurrentCartId } from '@graphcommerce/magento-cart'
|
|
1
|
+
import { useCurrentCartId } from '@graphcommerce/magento-cart'
|
|
3
2
|
import { useUrlQuery } from '@graphcommerce/next-ui'
|
|
4
3
|
import { useEffect, useState } from 'react'
|
|
5
4
|
|
|
@@ -20,10 +19,9 @@ let justLocked = false
|
|
|
20
19
|
* Todo: Block all operations on the cart while the cart is being blocked.
|
|
21
20
|
*/
|
|
22
21
|
export function useCartLock<E extends CartLockState>() {
|
|
23
|
-
const { currentCartId
|
|
22
|
+
const { currentCartId } = useCurrentCartId()
|
|
24
23
|
const [queryState, setRouterQuery] = useUrlQuery<E>()
|
|
25
24
|
const [, setForceRender] = useState(0)
|
|
26
|
-
const client = useApolloClient()
|
|
27
25
|
|
|
28
26
|
useEffect(() => {
|
|
29
27
|
const pageshow = (e: PageTransitionEvent) => {
|
|
@@ -40,7 +38,6 @@ export function useCartLock<E extends CartLockState>() {
|
|
|
40
38
|
const lock = (params: Omit<E, 'locked' | 'cart_id'>) => {
|
|
41
39
|
if (!currentCartId) return undefined
|
|
42
40
|
justLocked = true
|
|
43
|
-
cartLock(client.cache, true)
|
|
44
41
|
return setRouterQuery({
|
|
45
42
|
locked: '1',
|
|
46
43
|
cart_id: currentCartId,
|
|
@@ -49,14 +46,13 @@ export function useCartLock<E extends CartLockState>() {
|
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
const unlock = async (params: Omit<E, 'locked' | 'cart_id' | 'method'>) => {
|
|
52
|
-
cartLock(client.cache, false)
|
|
53
49
|
await setRouterQuery({ cart_id: null, locked: null, method: null, ...params } as E)
|
|
54
50
|
return queryState
|
|
55
51
|
}
|
|
56
52
|
|
|
57
53
|
const resulting: Omit<E, 'locked'> & { locked: boolean; justLocked: boolean } = {
|
|
58
54
|
...queryState,
|
|
59
|
-
locked:
|
|
55
|
+
locked: queryState.locked === '1' || Boolean(queryState.PayerID),
|
|
60
56
|
justLocked,
|
|
61
57
|
}
|
|
62
58
|
|
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": "8.0
|
|
5
|
+
"version": "8.1.0-canary.2",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^8.0
|
|
16
|
-
"@graphcommerce/framer-scroller": "^8.0
|
|
17
|
-
"@graphcommerce/graphql": "^8.0
|
|
18
|
-
"@graphcommerce/image": "^8.0
|
|
19
|
-
"@graphcommerce/magento-cart": "^8.0
|
|
20
|
-
"@graphcommerce/magento-cart-shipping-address": "^8.0
|
|
21
|
-
"@graphcommerce/magento-store": "^8.0
|
|
22
|
-
"@graphcommerce/next-ui": "^8.0
|
|
23
|
-
"@graphcommerce/prettier-config-pwa": "^8.0
|
|
24
|
-
"@graphcommerce/react-hook-form": "^8.0
|
|
25
|
-
"@graphcommerce/typescript-config-pwa": "^8.0
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.2",
|
|
16
|
+
"@graphcommerce/framer-scroller": "^8.1.0-canary.2",
|
|
17
|
+
"@graphcommerce/graphql": "^8.1.0-canary.2",
|
|
18
|
+
"@graphcommerce/image": "^8.1.0-canary.2",
|
|
19
|
+
"@graphcommerce/magento-cart": "^8.1.0-canary.2",
|
|
20
|
+
"@graphcommerce/magento-cart-shipping-address": "^8.1.0-canary.2",
|
|
21
|
+
"@graphcommerce/magento-store": "^8.1.0-canary.2",
|
|
22
|
+
"@graphcommerce/next-ui": "^8.1.0-canary.2",
|
|
23
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.2",
|
|
24
|
+
"@graphcommerce/react-hook-form": "^8.1.0-canary.2",
|
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.2",
|
|
26
26
|
"@lingui/core": "^4.2.1",
|
|
27
27
|
"@lingui/macro": "^4.2.1",
|
|
28
28
|
"@lingui/react": "^4.2.1",
|