@graphcommerce/magento-cart-payment-method 8.0.6-canary.3 → 8.0.6

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.
@@ -9,7 +9,7 @@ fragment PaymentMethodContext on Cart @injectable {
9
9
  prices {
10
10
  applied_taxes {
11
11
  amount {
12
- ...Money
12
+ value
13
13
  }
14
14
  }
15
15
  }
package/CHANGELOG.md CHANGED
@@ -1,23 +1,11 @@
1
1
  # Change Log
2
2
 
3
- ## 8.0.6-canary.3
4
-
5
- ## 8.0.6-canary.2
3
+ ## 8.0.6
6
4
 
7
5
  ### Patch Changes
8
6
 
9
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`43bd04a`](https://github.com/graphcommerce-org/graphcommerce/commit/43bd04a777c5800cc7e01bee1e123a5aad82f194) - Use the non resolved payment methods as a placeholder for the actual payment methods
10
- ([@FrankHarland](https://github.com/FrankHarland))
11
-
12
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of useFormPersist to the <FormPersist/> component to prevent rerenders.
13
- ([@FrankHarland](https://github.com/FrankHarland))
14
-
15
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`43bd04a`](https://github.com/graphcommerce-org/graphcommerce/commit/43bd04a777c5800cc7e01bee1e123a5aad82f194) - Prevent BillingPage query from rerunning on each mutation
16
- ([@FrankHarland](https://github.com/FrankHarland))
17
-
18
- ## 8.0.6-canary.1
19
-
20
- ## 8.0.6-canary.0
7
+ - [#2248](https://github.com/graphcommerce-org/graphcommerce/pull/2248) [`e262419`](https://github.com/graphcommerce-org/graphcommerce/commit/e2624194cc1c1b9bb625892c2856900c071c936c) - Compatibility with Magento 2.4.7
8
+ ([@paales](https://github.com/paales))
21
9
 
22
10
  ## 8.0.5
23
11
 
@@ -7,10 +7,10 @@ import {
7
7
  ActionCardProps,
8
8
  } from '@graphcommerce/next-ui'
9
9
  import {
10
- FormPersist,
11
10
  useForm,
12
11
  useFormCompose,
13
12
  UseFormComposeOptions,
13
+ useFormPersist,
14
14
  } from '@graphcommerce/react-hook-form'
15
15
  import { i18n } from '@lingui/core'
16
16
  import { Trans } from '@lingui/react'
@@ -84,6 +84,7 @@ export function PaymentMethodActionCardListForm(props: PaymentMethodActionCardLi
84
84
 
85
85
  const paymentMethod = watch('paymentMethod')
86
86
 
87
+ useFormPersist({ form, name: 'PaymentMethodActionCardList' })
87
88
  useFormCompose({ form, step: 1, submit, key: 'PaymentMethodActionCardList' })
88
89
 
89
90
  // todo: Do not useEffect to set value, usePaymentMethodContext should calculate these values.
@@ -108,24 +109,21 @@ export function PaymentMethodActionCardListForm(props: PaymentMethodActionCardLi
108
109
  if (!methods || methods.length < 1) return null
109
110
 
110
111
  return (
111
- <>
112
- <FormPersist form={form} name='PaymentMethodActionCardList' />
113
- <ActionCardListForm<PaymentOptionsProps & ActionCardProps, FormFields>
114
- control={control}
115
- name='paymentMethod'
116
- errorMessage={i18n._(/* i18n */ 'Please select a payment method')}
117
- collapse
118
- size='large'
119
- color='secondary'
120
- items={methods.map((method) => ({
121
- ...method,
122
- value: `${method.code}___${method.child}`,
123
- step,
124
- Container: FormDiv,
125
- disabled: !modules?.[method.code ?? ''],
126
- }))}
127
- render={PaymentMethodActionCard}
128
- />
129
- </>
112
+ <ActionCardListForm<PaymentOptionsProps & ActionCardProps, FormFields>
113
+ control={control}
114
+ name='paymentMethod'
115
+ errorMessage={i18n._(/* i18n */ 'Please select a payment method')}
116
+ collapse
117
+ size='large'
118
+ color='secondary'
119
+ items={methods.map((method) => ({
120
+ ...method,
121
+ value: `${method.code}___${method.child}`,
122
+ step,
123
+ Container: FormDiv,
124
+ disabled: !modules?.[method.code ?? ''],
125
+ }))}
126
+ render={PaymentMethodActionCard}
127
+ />
130
128
  )
131
129
  }
@@ -11,7 +11,6 @@ import {
11
11
  } from '../Api/PaymentMethod'
12
12
  import { PaymentMethodContextFragment } from '../Api/PaymentMethodContext.gql'
13
13
  import { GetPaymentMethodContextDocument } from './GetPaymentMethodContext.gql'
14
- import { filterNonNullableKeys, nonNullable } from '@graphcommerce/next-ui'
15
14
 
16
15
  type PaymentMethodContextProps = {
17
16
  methods: PaymentMethod[]
@@ -66,20 +65,17 @@ export function PaymentMethodContextProvider(props: PaymentMethodContextProvider
66
65
  },
67
66
  )
68
67
 
68
+ const [methods, setMethods] = useState<PaymentMethod[]>([])
69
69
  const [selectedMethod, setSelectedMethod] = useState<PaymentMethod>()
70
70
  const [selectedModule, setSelectedModule] = useState<PaymentModule>()
71
71
 
72
72
  const availableMethods = useMemo(() => {
73
- const allMethods = filterNonNullableKeys(cartContext?.available_payment_methods)
73
+ const allMethods = cartContext?.available_payment_methods ?? []
74
74
  const free = allMethods.find((method) => method?.code === 'free')
75
75
 
76
76
  return free ? [free] : allMethods
77
77
  }, [cartContext?.available_payment_methods])
78
78
 
79
- const [methods, setMethods] = useState<PaymentMethod[]>(
80
- availableMethods.map((m) => ({ ...m, code: `${m.code}_placeholder`, child: '' })),
81
- )
82
-
83
79
  // Expand the payment methods
84
80
  useEffect(() => {
85
81
  if (!cartContext) return // eslint-disable-next-line @typescript-eslint/no-floating-promises
@@ -10,7 +10,7 @@ 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
16
  })
@@ -11,10 +11,10 @@ import {
11
11
  } from '@graphcommerce/next-ui'
12
12
  import {
13
13
  Controller,
14
- FormPersist,
15
14
  useForm,
16
15
  useFormCompose,
17
16
  UseFormComposeOptions,
17
+ useFormPersist,
18
18
  } from '@graphcommerce/react-hook-form'
19
19
  import { i18n } from '@lingui/core'
20
20
  import { Box, FormControl, FormHelperText, SxProps, Theme } from '@mui/material'
@@ -51,6 +51,8 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
51
51
  defaultValues: { code: lockState.method },
52
52
  })
53
53
 
54
+ useFormPersist({ form, name: 'PaymentMethodToggle' })
55
+
54
56
  const { control, handleSubmit, watch, register, setValue, formState } = form
55
57
 
56
58
  const submitHandler = handleSubmit(() => {})
@@ -90,7 +92,6 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
90
92
  ...(Array.isArray(sx) ? sx : [sx]),
91
93
  ]}
92
94
  >
93
- <FormPersist form={form} name='PaymentMethodToggles' />
94
95
  <input type='hidden' {...register('code', { required: true })} required />
95
96
  <FormRow className={classes.root} sx={{ position: 'relative', padding: 0 }}>
96
97
  <ScrollerProvider scrollSnapAlign='center'>
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.6-canary.3",
5
+ "version": "8.0.6",
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.6-canary.3",
16
- "@graphcommerce/framer-scroller": "^8.0.6-canary.3",
17
- "@graphcommerce/graphql": "^8.0.6-canary.3",
18
- "@graphcommerce/image": "^8.0.6-canary.3",
19
- "@graphcommerce/magento-cart": "^8.0.6-canary.3",
20
- "@graphcommerce/magento-cart-shipping-address": "^8.0.6-canary.3",
21
- "@graphcommerce/magento-store": "^8.0.6-canary.3",
22
- "@graphcommerce/next-ui": "^8.0.6-canary.3",
23
- "@graphcommerce/prettier-config-pwa": "^8.0.6-canary.3",
24
- "@graphcommerce/react-hook-form": "^8.0.6-canary.3",
25
- "@graphcommerce/typescript-config-pwa": "^8.0.6-canary.3",
15
+ "@graphcommerce/eslint-config-pwa": "^8.0.6",
16
+ "@graphcommerce/framer-scroller": "^8.0.6",
17
+ "@graphcommerce/graphql": "^8.0.6",
18
+ "@graphcommerce/image": "^8.0.6",
19
+ "@graphcommerce/magento-cart": "^8.0.6",
20
+ "@graphcommerce/magento-cart-shipping-address": "^8.0.6",
21
+ "@graphcommerce/magento-store": "^8.0.6",
22
+ "@graphcommerce/next-ui": "^8.0.6",
23
+ "@graphcommerce/prettier-config-pwa": "^8.0.6",
24
+ "@graphcommerce/react-hook-form": "^8.0.6",
25
+ "@graphcommerce/typescript-config-pwa": "^8.0.6",
26
26
  "@lingui/core": "^4.2.1",
27
27
  "@lingui/macro": "^4.2.1",
28
28
  "@lingui/react": "^4.2.1",