@graphcommerce/magento-cart-payment-method 9.0.0-canary.78 → 9.0.0-canary.80
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
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Button,
|
|
4
|
-
FormDiv,
|
|
5
|
-
ActionCardItemRenderProps,
|
|
6
|
-
ActionCardListForm,
|
|
7
|
-
ActionCardProps,
|
|
8
|
-
} from '@graphcommerce/next-ui'
|
|
1
|
+
import { ActionCardItemRenderProps, ActionCardListForm } from '@graphcommerce/ecommerce-ui'
|
|
2
|
+
import { ActionCard, ActionCardProps, Button, FormDiv } from '@graphcommerce/next-ui'
|
|
9
3
|
import {
|
|
10
4
|
FormPersist,
|
|
11
5
|
useForm,
|
|
@@ -75,15 +69,17 @@ export function PaymentMethodActionCardListForm(props: PaymentMethodActionCardLi
|
|
|
75
69
|
const [lockState] = useCartLock()
|
|
76
70
|
|
|
77
71
|
type FormFields = { code: string | null; paymentMethod?: string }
|
|
78
|
-
const form = useForm<FormFields>({
|
|
79
|
-
defaultValues: { code: lockState.method },
|
|
80
|
-
})
|
|
72
|
+
const form = useForm<FormFields>({})
|
|
81
73
|
|
|
82
74
|
const { control, handleSubmit, watch, setValue } = form
|
|
83
75
|
const submit = handleSubmit(() => {})
|
|
84
76
|
|
|
85
77
|
const paymentMethod = watch('paymentMethod')
|
|
86
78
|
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (lockState.method) setValue('code', lockState.method)
|
|
81
|
+
}, [lockState.method, setValue])
|
|
82
|
+
|
|
87
83
|
useFormCompose({ form, step: 1, submit, key: 'PaymentMethodActionCardList' })
|
|
88
84
|
|
|
89
85
|
// todo: Do not useEffect to set value, usePaymentMethodContext should calculate these values.
|
|
@@ -116,6 +112,7 @@ export function PaymentMethodActionCardListForm(props: PaymentMethodActionCardLi
|
|
|
116
112
|
collapse
|
|
117
113
|
size='large'
|
|
118
114
|
color='secondary'
|
|
115
|
+
required
|
|
119
116
|
items={methods.map((method) => ({
|
|
120
117
|
...method,
|
|
121
118
|
value: `${method.code}___${method.child}`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApolloCartErrorSnackbar } from '@graphcommerce/magento-cart'
|
|
2
|
-
import { LinkOrButton, LinkOrButtonProps } from '@graphcommerce/next-ui'
|
|
2
|
+
import { ErrorSnackbar, LinkOrButton, LinkOrButtonProps } from '@graphcommerce/next-ui'
|
|
3
3
|
import {
|
|
4
4
|
ComposedSubmit,
|
|
5
5
|
ComposedSubmitProps,
|
|
@@ -50,8 +50,9 @@ export function PaymentMethodButton(props: PaymentMethodButtonProps) {
|
|
|
50
50
|
return (
|
|
51
51
|
<ComposedSubmit
|
|
52
52
|
onSubmitSuccessful={onSubmitSuccessful}
|
|
53
|
-
render={({ submit, buttonState, error }) => {
|
|
53
|
+
render={({ submit, buttonState, error, rootThrown }) => {
|
|
54
54
|
const errorVal = buttonState.isSubmitting ? undefined : error
|
|
55
|
+
const rootMessage = buttonState.isSubmitting ? undefined : rootThrown?.message
|
|
55
56
|
const button = (
|
|
56
57
|
<PaymentMethodButtonRenderer
|
|
57
58
|
buttonProps={buttonProps}
|
|
@@ -66,6 +67,9 @@ export function PaymentMethodButton(props: PaymentMethodButtonProps) {
|
|
|
66
67
|
<>
|
|
67
68
|
{button}
|
|
68
69
|
<ApolloCartErrorSnackbar key='error' error={errorVal} />
|
|
70
|
+
<ErrorSnackbar variant='pill' severity='error' open={!!rootMessage}>
|
|
71
|
+
<>{rootMessage}</>
|
|
72
|
+
</ErrorSnackbar>
|
|
69
73
|
</>
|
|
70
74
|
)
|
|
71
75
|
}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useFormGqlMutationCart } from '@graphcommerce/magento-cart'
|
|
2
2
|
import { useFormCompose } from '@graphcommerce/react-hook-form'
|
|
3
|
+
import { t } from '@lingui/macro'
|
|
3
4
|
import { PaymentPlaceOrderProps } from '../Api/PaymentMethod'
|
|
4
5
|
import { usePaymentMethodContext } from '../PaymentMethodContext/paymentMethodContextType'
|
|
5
6
|
import { PaymentMethodPlaceOrderNoopDocument } from './PaymentMethodPlaceOrderNoop.gql'
|
|
@@ -10,7 +11,11 @@ export function PaymentMethodPlaceOrderNoop(props: PaymentPlaceOrderProps) {
|
|
|
10
11
|
|
|
11
12
|
const form = useFormGqlMutationCart(PaymentMethodPlaceOrderNoopDocument, {
|
|
12
13
|
onComplete: async (result) => {
|
|
13
|
-
if (!result.data?.placeOrder?.order)
|
|
14
|
+
if (!result.data?.placeOrder?.order)
|
|
15
|
+
throw Error(
|
|
16
|
+
t`An error occurred while processing your payment. Please contact the store owner`,
|
|
17
|
+
)
|
|
18
|
+
|
|
14
19
|
await onSuccess(result.data.placeOrder.order.order_number)
|
|
15
20
|
},
|
|
16
21
|
submitWhileLocked: true,
|
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": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.80",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,17 +12,18 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/
|
|
16
|
-
"@graphcommerce/
|
|
17
|
-
"@graphcommerce/
|
|
18
|
-
"@graphcommerce/
|
|
19
|
-
"@graphcommerce/
|
|
20
|
-
"@graphcommerce/magento-cart
|
|
21
|
-
"@graphcommerce/magento-
|
|
22
|
-
"@graphcommerce/
|
|
23
|
-
"@graphcommerce/
|
|
24
|
-
"@graphcommerce/
|
|
25
|
-
"@graphcommerce/
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.0.0-canary.80",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.80",
|
|
17
|
+
"@graphcommerce/framer-scroller": "^9.0.0-canary.80",
|
|
18
|
+
"@graphcommerce/graphql": "^9.0.0-canary.80",
|
|
19
|
+
"@graphcommerce/image": "^9.0.0-canary.80",
|
|
20
|
+
"@graphcommerce/magento-cart": "^9.0.0-canary.80",
|
|
21
|
+
"@graphcommerce/magento-cart-shipping-address": "^9.0.0-canary.80",
|
|
22
|
+
"@graphcommerce/magento-store": "^9.0.0-canary.80",
|
|
23
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.80",
|
|
24
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.80",
|
|
25
|
+
"@graphcommerce/react-hook-form": "^9.0.0-canary.80",
|
|
26
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.80",
|
|
26
27
|
"@lingui/core": "^4.2.1",
|
|
27
28
|
"@lingui/macro": "^4.2.1",
|
|
28
29
|
"@lingui/react": "^4.2.1",
|