@graphcommerce/magento-cart-payment-method 8.1.0-canary.5 → 8.1.0-canary.50
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/Api/AvailablePaymentMethod/AvailablePaymentMethod.graphql +1 -1
- package/Api/PaymentMethodContext.graphql +1 -1
- package/Api/PaymentMethodUpdated.graphql +1 -1
- package/Api/SelectedPaymentMethod/SelectedPaymentMethod.graphql +1 -1
- package/CHANGELOG.md +110 -0
- package/PaymentMethodActionCardList/PaymentMethodActionCardListForm.tsx +2 -2
- package/PaymentMethodButton/PaymentMethodButton.tsx +1 -1
- package/PaymentMethodContext/PaymentMethodContext.tsx +4 -29
- package/PaymentMethodContext/paymentMethodContextType.ts +28 -0
- package/PaymentMethodOptions/PaymentMethodOptions.tsx +1 -1
- package/PaymentMethodPlaceOrder/PaymentMethodPlaceOrder.tsx +3 -2
- package/PaymentMethodPlaceOrderNoop/PaymentMethodPlaceOrderNoop.tsx +3 -2
- package/PaymentMethodToggles/PaymentMethodToggles.tsx +2 -2
- package/index.ts +1 -0
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.1.0-canary.50
|
|
4
|
+
|
|
5
|
+
## 8.1.0-canary.49
|
|
6
|
+
|
|
7
|
+
## 8.1.0-canary.48
|
|
8
|
+
|
|
9
|
+
## 8.1.0-canary.47
|
|
10
|
+
|
|
11
|
+
## 8.1.0-canary.46
|
|
12
|
+
|
|
13
|
+
## 8.1.0-canary.45
|
|
14
|
+
|
|
15
|
+
## 8.1.0-canary.44
|
|
16
|
+
|
|
17
|
+
## 8.1.0-canary.43
|
|
18
|
+
|
|
19
|
+
## 8.1.0-canary.42
|
|
20
|
+
|
|
21
|
+
## 8.1.0-canary.41
|
|
22
|
+
|
|
23
|
+
## 8.1.0-canary.40
|
|
24
|
+
|
|
25
|
+
## 8.1.0-canary.39
|
|
26
|
+
|
|
27
|
+
## 8.1.0-canary.38
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Fix bug with persist not applying saved changes by moving <FromPersist/> below the form components
|
|
32
|
+
([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
33
|
+
|
|
34
|
+
## 8.1.0-canary.37
|
|
35
|
+
|
|
36
|
+
## 8.1.0-canary.36
|
|
37
|
+
|
|
38
|
+
## 8.1.0-canary.35
|
|
39
|
+
|
|
40
|
+
## 8.1.0-canary.34
|
|
41
|
+
|
|
42
|
+
## 8.1.0-canary.33
|
|
43
|
+
|
|
44
|
+
## 8.1.0-canary.32
|
|
45
|
+
|
|
46
|
+
## 8.1.0-canary.31
|
|
47
|
+
|
|
48
|
+
## 8.1.0-canary.30
|
|
49
|
+
|
|
50
|
+
## 8.1.0-canary.29
|
|
51
|
+
|
|
52
|
+
## 8.1.0-canary.28
|
|
53
|
+
|
|
54
|
+
## 8.1.0-canary.27
|
|
55
|
+
|
|
56
|
+
## 8.1.0-canary.26
|
|
57
|
+
|
|
58
|
+
## 8.1.0-canary.25
|
|
59
|
+
|
|
60
|
+
## 8.1.0-canary.24
|
|
61
|
+
|
|
62
|
+
## 8.1.0-canary.23
|
|
63
|
+
|
|
64
|
+
## 8.1.0-canary.22
|
|
65
|
+
|
|
66
|
+
## 8.1.0-canary.21
|
|
67
|
+
|
|
68
|
+
## 8.1.0-canary.20
|
|
69
|
+
|
|
70
|
+
## 8.1.0-canary.19
|
|
71
|
+
|
|
72
|
+
## 8.1.0-canary.18
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- [#2277](https://github.com/graphcommerce-org/graphcommerce/pull/2277) [`f9199f7`](https://github.com/graphcommerce-org/graphcommerce/commit/f9199f798583138a68dd641ea6637375c487f29b) - Solve issue where Braintree wouldn't place the order after successfully validating a Credit Card.
|
|
77
|
+
([@paales](https://github.com/paales))
|
|
78
|
+
|
|
79
|
+
## 8.1.0-canary.17
|
|
80
|
+
|
|
81
|
+
## 8.1.0-canary.16
|
|
82
|
+
|
|
83
|
+
## 8.1.0-canary.15
|
|
84
|
+
|
|
85
|
+
## 8.1.0-canary.14
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- [`831d7cd`](https://github.com/graphcommerce-org/graphcommerce/commit/831d7cd64a40b7b58748fd9637199b88938e75b7) - Compatibility with Magento 2.4.7
|
|
90
|
+
([@paales](https://github.com/paales))
|
|
91
|
+
|
|
92
|
+
## 8.1.0-canary.13
|
|
93
|
+
|
|
94
|
+
## 8.1.0-canary.12
|
|
95
|
+
|
|
96
|
+
## 8.1.0-canary.11
|
|
97
|
+
|
|
98
|
+
## 8.1.0-canary.10
|
|
99
|
+
|
|
100
|
+
## 8.1.0-canary.9
|
|
101
|
+
|
|
102
|
+
## 8.1.0-canary.8
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- [#2247](https://github.com/graphcommerce-org/graphcommerce/pull/2247) [`d345474`](https://github.com/graphcommerce-org/graphcommerce/commit/d345474fb190d158629cd5fd5e68a78724fa2fb6) - Due to a cyclic dependency the actual PaymentMethodPlaceOrder button would sometimes be undefined.
|
|
107
|
+
([@paales](https://github.com/paales))
|
|
108
|
+
|
|
109
|
+
## 8.1.0-canary.7
|
|
110
|
+
|
|
111
|
+
## 8.1.0-canary.6
|
|
112
|
+
|
|
3
113
|
## 8.1.0-canary.5
|
|
4
114
|
|
|
5
115
|
## 8.0.6-canary.4
|
|
@@ -17,7 +17,7 @@ import { Trans } from '@lingui/react'
|
|
|
17
17
|
import { SxProps, Theme } from '@mui/material'
|
|
18
18
|
import { useEffect } from 'react'
|
|
19
19
|
import { PaymentOptionsProps } from '../Api/PaymentMethod'
|
|
20
|
-
import { usePaymentMethodContext } from '../PaymentMethodContext/
|
|
20
|
+
import { usePaymentMethodContext } from '../PaymentMethodContext/paymentMethodContextType'
|
|
21
21
|
import { useCartLock } from '../hooks'
|
|
22
22
|
|
|
23
23
|
function PaymentMethodActionCard(
|
|
@@ -109,7 +109,6 @@ export function PaymentMethodActionCardListForm(props: PaymentMethodActionCardLi
|
|
|
109
109
|
|
|
110
110
|
return (
|
|
111
111
|
<>
|
|
112
|
-
<FormPersist form={form} name='PaymentMethodActionCardList' />
|
|
113
112
|
<ActionCardListForm<PaymentOptionsProps & ActionCardProps, FormFields>
|
|
114
113
|
control={control}
|
|
115
114
|
name='paymentMethod'
|
|
@@ -126,6 +125,7 @@ export function PaymentMethodActionCardListForm(props: PaymentMethodActionCardLi
|
|
|
126
125
|
}))}
|
|
127
126
|
render={PaymentMethodActionCard}
|
|
128
127
|
/>
|
|
128
|
+
<FormPersist form={form} name='PaymentMethodActionCardList' />
|
|
129
129
|
</>
|
|
130
130
|
)
|
|
131
131
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ComposedSubmitProps,
|
|
6
6
|
ComposedSubmitRenderComponentProps,
|
|
7
7
|
} from '@graphcommerce/react-hook-form'
|
|
8
|
-
import { usePaymentMethodContext } from '../PaymentMethodContext/
|
|
8
|
+
import { usePaymentMethodContext } from '../PaymentMethodContext/paymentMethodContextType'
|
|
9
9
|
|
|
10
10
|
export type PaymentMethodButtonProps = LinkOrButtonProps & { display?: 'inline' | 'block' } & Pick<
|
|
11
11
|
ComposedSubmitProps,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useApolloClient } from '@graphcommerce/graphql'
|
|
2
2
|
import { useCartQuery, useClearCurrentCartId } from '@graphcommerce/magento-cart'
|
|
3
|
+
import { filterNonNullableKeys } from '@graphcommerce/next-ui'
|
|
3
4
|
import { useEventCallback } from '@mui/material'
|
|
4
5
|
import { useRouter } from 'next/router'
|
|
5
|
-
import React, {
|
|
6
|
+
import React, { useEffect, useMemo, useState } from 'react'
|
|
6
7
|
import {
|
|
7
8
|
ExpandPaymentMethodsContext,
|
|
8
9
|
PaymentMethod,
|
|
@@ -11,20 +12,7 @@ import {
|
|
|
11
12
|
} from '../Api/PaymentMethod'
|
|
12
13
|
import { PaymentMethodContextFragment } from '../Api/PaymentMethodContext.gql'
|
|
13
14
|
import { GetPaymentMethodContextDocument } from './GetPaymentMethodContext.gql'
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
type PaymentMethodContextProps = {
|
|
17
|
-
methods: PaymentMethod[]
|
|
18
|
-
selectedMethod?: PaymentMethod
|
|
19
|
-
setSelectedMethod: (method: PaymentMethod | undefined) => void
|
|
20
|
-
modules: PaymentMethodModules
|
|
21
|
-
selectedModule?: PaymentModule
|
|
22
|
-
setSelectedModule: (module: PaymentModule | undefined) => void
|
|
23
|
-
onSuccess: (orderNumber: string) => Promise<void>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const paymentMethodContext = React.createContext<PaymentMethodContextProps | undefined>(undefined)
|
|
27
|
-
paymentMethodContext.displayName = 'PaymentMethodContext'
|
|
15
|
+
import { PaymentMethodContextType, paymentMethodContext } from './paymentMethodContextType'
|
|
28
16
|
|
|
29
17
|
export type PaymentMethodContextProviderProps = {
|
|
30
18
|
modules?: PaymentMethodModules
|
|
@@ -55,7 +43,7 @@ export function PaymentMethodContextProvider(props: PaymentMethodContextProvider
|
|
|
55
43
|
[client, context?.data?.cart],
|
|
56
44
|
)
|
|
57
45
|
|
|
58
|
-
const onSuccessCb: NonNullable<
|
|
46
|
+
const onSuccessCb: NonNullable<PaymentMethodContextType['onSuccess']> = useEventCallback(
|
|
59
47
|
async (orderNumber) => {
|
|
60
48
|
await onSuccess?.(orderNumber, context.data?.cart)
|
|
61
49
|
await push({
|
|
@@ -117,16 +105,3 @@ export function PaymentMethodContextProvider(props: PaymentMethodContextProvider
|
|
|
117
105
|
</paymentMethodContext.Provider>
|
|
118
106
|
)
|
|
119
107
|
}
|
|
120
|
-
|
|
121
|
-
export function usePaymentMethodContext(optional: true): PaymentMethodContextProps | undefined
|
|
122
|
-
export function usePaymentMethodContext(optional?: false): PaymentMethodContextProps
|
|
123
|
-
export function usePaymentMethodContext(optional = false) {
|
|
124
|
-
const context = useContext(paymentMethodContext)
|
|
125
|
-
if (!optional && typeof context === 'undefined') {
|
|
126
|
-
throw Error(
|
|
127
|
-
'usePaymentMethodContext must be used within a PaymentMethodContextProvider or provide the optional=true argument',
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return useContext(paymentMethodContext)
|
|
132
|
-
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import type { PaymentMethod, PaymentMethodModules, PaymentModule } from '../Api/PaymentMethod'
|
|
3
|
+
|
|
4
|
+
export type PaymentMethodContextType = {
|
|
5
|
+
methods: PaymentMethod[]
|
|
6
|
+
selectedMethod?: PaymentMethod
|
|
7
|
+
setSelectedMethod: (method: PaymentMethod | undefined) => void
|
|
8
|
+
modules: PaymentMethodModules
|
|
9
|
+
selectedModule?: PaymentModule
|
|
10
|
+
setSelectedModule: (module: PaymentModule | undefined) => void
|
|
11
|
+
onSuccess: (orderNumber: string) => Promise<void>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const paymentMethodContext = createContext<PaymentMethodContextType | undefined>(undefined)
|
|
15
|
+
paymentMethodContext.displayName = 'PaymentMethodContext'
|
|
16
|
+
|
|
17
|
+
export function usePaymentMethodContext(optional: true): PaymentMethodContextType | undefined
|
|
18
|
+
export function usePaymentMethodContext(optional?: false): PaymentMethodContextType
|
|
19
|
+
export function usePaymentMethodContext(optional = false) {
|
|
20
|
+
const context = useContext(paymentMethodContext)
|
|
21
|
+
if (!optional && typeof context === 'undefined') {
|
|
22
|
+
throw Error(
|
|
23
|
+
'usePaymentMethodContext must be used within a PaymentMethodContextProvider or provide the optional=true argument',
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return useContext(paymentMethodContext)
|
|
28
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extendableComponent } from '@graphcommerce/next-ui'
|
|
2
2
|
import { Box, SxProps, Theme } from '@mui/material'
|
|
3
3
|
import { PaymentMethodOptionsProps } from '../Api/PaymentMethod'
|
|
4
|
-
import { usePaymentMethodContext } from '../PaymentMethodContext/
|
|
4
|
+
import { usePaymentMethodContext } from '../PaymentMethodContext/paymentMethodContextType'
|
|
5
5
|
|
|
6
6
|
const name = 'PaymentMethodOptions' as const
|
|
7
7
|
const parts = ['root'] as const
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseFormComposeOptions } from '@graphcommerce/react-hook-form'
|
|
2
|
-
import { usePaymentMethodContext } from '../PaymentMethodContext/
|
|
2
|
+
import { usePaymentMethodContext } from '../PaymentMethodContext/paymentMethodContextType'
|
|
3
3
|
|
|
4
4
|
export type PaymentMethodPlaceOrderProps = Pick<UseFormComposeOptions, 'step'>
|
|
5
5
|
|
|
@@ -7,6 +7,7 @@ export function PaymentMethodPlaceOrder(props: PaymentMethodPlaceOrderProps) {
|
|
|
7
7
|
const { step } = props
|
|
8
8
|
const { selectedMethod, selectedModule } = usePaymentMethodContext()
|
|
9
9
|
|
|
10
|
-
if (!selectedModule || !selectedMethod?.code) return null
|
|
10
|
+
if (!selectedModule || !selectedMethod?.code || !selectedModule.PaymentPlaceOrder) return null
|
|
11
|
+
|
|
11
12
|
return <selectedModule.PaymentPlaceOrder {...selectedMethod} step={step} />
|
|
12
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useFormGqlMutationCart } from '@graphcommerce/magento-cart'
|
|
2
2
|
import { useFormCompose } from '@graphcommerce/react-hook-form'
|
|
3
3
|
import { PaymentPlaceOrderProps } from '../Api/PaymentMethod'
|
|
4
|
-
import { usePaymentMethodContext } from '../PaymentMethodContext/
|
|
4
|
+
import { usePaymentMethodContext } from '../PaymentMethodContext/paymentMethodContextType'
|
|
5
5
|
import { PaymentMethodPlaceOrderNoopDocument } from './PaymentMethodPlaceOrderNoop.gql'
|
|
6
6
|
|
|
7
7
|
export function PaymentMethodPlaceOrderNoop(props: PaymentPlaceOrderProps) {
|
|
@@ -10,9 +10,10 @@ export function PaymentMethodPlaceOrderNoop(props: PaymentPlaceOrderProps) {
|
|
|
10
10
|
|
|
11
11
|
const form = useFormGqlMutationCart(PaymentMethodPlaceOrderNoopDocument, {
|
|
12
12
|
onComplete: async (result) => {
|
|
13
|
-
if (!result.data?.placeOrder) return
|
|
13
|
+
if (!result.data?.placeOrder?.order) return
|
|
14
14
|
await onSuccess(result.data.placeOrder.order.order_number)
|
|
15
15
|
},
|
|
16
|
+
submitWhileLocked: true,
|
|
16
17
|
})
|
|
17
18
|
|
|
18
19
|
const { handleSubmit } = form
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import { i18n } from '@lingui/core'
|
|
20
20
|
import { Box, FormControl, FormHelperText, SxProps, Theme } from '@mui/material'
|
|
21
21
|
import { useEffect } from 'react'
|
|
22
|
-
import { usePaymentMethodContext } from '../PaymentMethodContext/
|
|
22
|
+
import { usePaymentMethodContext } from '../PaymentMethodContext/paymentMethodContextType'
|
|
23
23
|
import { useCartLock } from '../hooks/useCartLock'
|
|
24
24
|
|
|
25
25
|
export type PaymentMethodTogglesProps = Pick<UseFormComposeOptions, 'step'> & {
|
|
@@ -90,7 +90,6 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
|
|
|
90
90
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
91
91
|
]}
|
|
92
92
|
>
|
|
93
|
-
<FormPersist form={form} name='PaymentMethodToggles' />
|
|
94
93
|
<input type='hidden' {...register('code', { required: true })} required />
|
|
95
94
|
<FormRow className={classes.root} sx={{ position: 'relative', padding: 0 }}>
|
|
96
95
|
<ScrollerProvider scrollSnapAlign='center'>
|
|
@@ -215,6 +214,7 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
|
|
|
215
214
|
</Box>
|
|
216
215
|
</ScrollerProvider>
|
|
217
216
|
</FormRow>
|
|
217
|
+
<FormPersist form={form} name='PaymentMethodToggles' />
|
|
218
218
|
</Form>
|
|
219
219
|
)
|
|
220
220
|
}
|
package/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './Api/PaymentMethod'
|
|
|
2
2
|
export * from './hooks'
|
|
3
3
|
export * from './PaymentMethodButton/PaymentMethodButton'
|
|
4
4
|
export * from './PaymentMethodContext/PaymentMethodContext'
|
|
5
|
+
export * from './PaymentMethodContext/paymentMethodContextType'
|
|
5
6
|
export * from './PaymentMethodOptions/PaymentMethodOptions'
|
|
6
7
|
export * from './PaymentMethodOptionsNoop/PaymentMethodOptionsNoop'
|
|
7
8
|
export * from './PaymentMethodOptionsNoop/PaymentMethodOptionsNoop.gql'
|
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.1.0-canary.
|
|
5
|
+
"version": "8.1.0-canary.50",
|
|
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.1.0-canary.
|
|
16
|
-
"@graphcommerce/framer-scroller": "^8.1.0-canary.
|
|
17
|
-
"@graphcommerce/graphql": "^8.1.0-canary.
|
|
18
|
-
"@graphcommerce/image": "^8.1.0-canary.
|
|
19
|
-
"@graphcommerce/magento-cart": "^8.1.0-canary.
|
|
20
|
-
"@graphcommerce/magento-cart-shipping-address": "^8.1.0-canary.
|
|
21
|
-
"@graphcommerce/magento-store": "^8.1.0-canary.
|
|
22
|
-
"@graphcommerce/next-ui": "^8.1.0-canary.
|
|
23
|
-
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.
|
|
24
|
-
"@graphcommerce/react-hook-form": "^8.1.0-canary.
|
|
25
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.50",
|
|
16
|
+
"@graphcommerce/framer-scroller": "^8.1.0-canary.50",
|
|
17
|
+
"@graphcommerce/graphql": "^8.1.0-canary.50",
|
|
18
|
+
"@graphcommerce/image": "^8.1.0-canary.50",
|
|
19
|
+
"@graphcommerce/magento-cart": "^8.1.0-canary.50",
|
|
20
|
+
"@graphcommerce/magento-cart-shipping-address": "^8.1.0-canary.50",
|
|
21
|
+
"@graphcommerce/magento-store": "^8.1.0-canary.50",
|
|
22
|
+
"@graphcommerce/next-ui": "^8.1.0-canary.50",
|
|
23
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.50",
|
|
24
|
+
"@graphcommerce/react-hook-form": "^8.1.0-canary.50",
|
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.50",
|
|
26
26
|
"@lingui/core": "^4.2.1",
|
|
27
27
|
"@lingui/macro": "^4.2.1",
|
|
28
28
|
"@lingui/react": "^4.2.1",
|