@graphcommerce/magento-cart-payment-method 10.0.0-canary.67 → 10.0.0-canary.72

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.
@@ -22,7 +22,7 @@ export type PaymentOptionsProps = PaymentMethod & PaymentMethodOptionsProps
22
22
  export type PaymentHandlerProps = { code: string }
23
23
 
24
24
  export type ExpandPaymentMethodsContext = Partial<PaymentMethodContextFragment> & {
25
- client: ApolloClient<object>
25
+ client: ApolloClient
26
26
  }
27
27
 
28
28
  export type ExpandPaymentMethods = (
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.0.0-canary.72
4
+
5
+ ## 10.0.0-canary.71
6
+
7
+ ## 10.0.0-canary.70
8
+
9
+ ### Major Changes
10
+
11
+ - [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
12
+
13
+ ## 10.0.0-canary.69
14
+
15
+ ## 10.0.0-canary.68
16
+
3
17
  ## 10.0.0-canary.67
4
18
 
5
19
  ## 10.0.0-canary.66
@@ -1,7 +1,7 @@
1
1
  import type { ActionCardItemRenderProps } from '@graphcommerce/ecommerce-ui'
2
2
  import { ActionCardListForm } from '@graphcommerce/ecommerce-ui'
3
3
  import type { ActionCardProps } from '@graphcommerce/next-ui'
4
- import { ActionCard, Button, FormDiv } from '@graphcommerce/next-ui'
4
+ import { ActionCard, Button, FormDiv, sxx } from '@graphcommerce/next-ui'
5
5
  import type { UseFormComposeOptions } from '@graphcommerce/react-hook-form'
6
6
  import { FormPersist, useForm, useFormCompose } from '@graphcommerce/react-hook-form'
7
7
  import { t } from '@lingui/core/macro'
@@ -31,14 +31,14 @@ function PaymentMethodActionCard(
31
31
  <Card
32
32
  code={code}
33
33
  child={child}
34
- sx={[
34
+ sx={sxx(
35
35
  {
36
36
  '& .ActionCard-title': { typography: 'h6' },
37
37
  '& .ActionCard-details': { lineHeight: 1.5 },
38
38
  '& .ActionCard-image svg, .ActionCard-image img': { width: '32px', height: '32px' },
39
39
  },
40
- ...(Array.isArray(sx) ? sx : [sx]),
41
- ]}
40
+ sx,
41
+ )}
42
42
  action={
43
43
  <Button disableRipple variant='inline' color='secondary' tabIndex={-1}>
44
44
  <Trans>Select</Trans>
@@ -1,4 +1,4 @@
1
- import { extendableComponent } from '@graphcommerce/next-ui'
1
+ import { extendableComponent, sxx } from '@graphcommerce/next-ui'
2
2
  import type { SxProps, Theme } from '@mui/material'
3
3
  import { Box } from '@mui/material'
4
4
  import type { PaymentMethodOptionsProps } from '../Api/PaymentMethod'
@@ -17,10 +17,7 @@ export function PaymentMethodOptions(props: PaymentMethodOptionsProps & { sx?: S
17
17
  const { selectedMethod, selectedModule } = usePaymentMethodContext()
18
18
 
19
19
  return (
20
- <Box
21
- className={classes.root}
22
- sx={[(theme) => ({ marginBottom: theme.spacings.sm }), ...(Array.isArray(sx) ? sx : [sx])]}
23
- >
20
+ <Box className={classes.root} sx={sxx((theme) => ({ marginBottom: theme.spacings.sm }), sx)}>
24
21
  {selectedModule && selectedMethod && (
25
22
  <Box key={selectedMethod.code}>
26
23
  <selectedModule.PaymentOptions {...selectedMethod} {...optionsProps} />
@@ -12,7 +12,10 @@ export function PaymentMethodPlaceOrderNoop(props: PaymentPlaceOrderProps) {
12
12
  const form = useFormGqlMutationCart(PaymentMethodPlaceOrderNoopDocument, {
13
13
  onComplete: async (result) => {
14
14
  assertOrderPlaced(result)
15
- await onSuccess(result.data.placeOrder.order.order_number)
15
+ // After assertOrderPlaced, result.data.placeOrder.order.order_number is guaranteed
16
+ const orderNumber = (result.data as { placeOrder: { order: { order_number: string } } })
17
+ .placeOrder.order.order_number
18
+ await onSuccess(orderNumber)
16
19
  },
17
20
  submitWhileLocked: true,
18
21
  })
@@ -1,21 +1,23 @@
1
- import type { FetchResult } from '@graphcommerce/graphql'
2
- import { ApolloError } from '@graphcommerce/graphql'
1
+ import type { ApolloLink } from '@graphcommerce/graphql'
2
+ import { CombinedGraphQLErrors } from '@apollo/client/errors'
3
3
  import { t } from '@lingui/core/macro'
4
4
  import type { PaymentMethodPlaceOrderNoopMutation } from './PaymentMethodPlaceOrderNoop.gql'
5
5
 
6
- export type PlacedOrder<T extends FetchResult<PaymentMethodPlaceOrderNoopMutation>> = NonNullable<
7
- NonNullable<NonNullable<T['data']>['placeOrder']>['order']
8
- >
6
+ type PlaceOrderResult = ApolloLink.Result<PaymentMethodPlaceOrderNoopMutation>
9
7
 
10
- export type AssertedOrderPlaced<T extends FetchResult<PaymentMethodPlaceOrderNoopMutation>> = T & {
8
+ export type PlacedOrder = {
9
+ order_number: string
10
+ }
11
+
12
+ export type AssertedOrderPlaced = PlaceOrderResult & {
11
13
  data: {
12
- placeOrder: { order: PlacedOrder<T> }
14
+ placeOrder: { order: PlacedOrder }
13
15
  }
14
16
  }
15
17
 
16
- export function throwGenericPlaceOrderError() {
17
- throw new ApolloError({
18
- graphQLErrors: [
18
+ export function throwGenericPlaceOrderError(): never {
19
+ throw new CombinedGraphQLErrors({
20
+ errors: [
19
21
  {
20
22
  message: t`An error occurred while processing your payment. Please contact the store owner`,
21
23
  },
@@ -24,20 +26,26 @@ export function throwGenericPlaceOrderError() {
24
26
  }
25
27
 
26
28
  /** Assert that the order was place successfully. */
27
- export function assertOrderPlaced<T extends FetchResult<PaymentMethodPlaceOrderNoopMutation>>(
28
- result: T,
29
- ): asserts result is AssertedOrderPlaced<T> {
29
+ export function assertOrderPlaced(result: PlaceOrderResult): asserts result is AssertedOrderPlaced {
30
+ // Check for GraphQL errors in the result
30
31
  if (result.errors && result.errors.length > 0) {
31
- const graphQLErrors = result.errors.filter((e) => e !== null)
32
- throw new ApolloError({ graphQLErrors })
32
+ throw new CombinedGraphQLErrors(result)
33
33
  }
34
34
 
35
- if (result.data?.placeOrder?.errors && result.data.placeOrder.errors.length > 0) {
36
- const graphQLErrors = result.data.placeOrder.errors.filter((e) => e !== null)
37
- throw new ApolloError({ graphQLErrors })
35
+ // Check for place order specific errors
36
+ const placeOrderData = result.data?.placeOrder as
37
+ | { errors?: { message: string }[] | null; order?: { order_number?: string } | null }
38
+ | null
39
+ | undefined
40
+
41
+ if (placeOrderData?.errors && placeOrderData.errors.length > 0) {
42
+ throw new CombinedGraphQLErrors({
43
+ errors: placeOrderData.errors.filter((e) => e !== null),
44
+ })
38
45
  }
39
46
 
40
- if (!result.data?.placeOrder?.order?.order_number) {
47
+ const orderNumber = placeOrderData?.order?.order_number
48
+ if (!orderNumber) {
41
49
  console.info('Error while placing order', result)
42
50
  throwGenericPlaceOrderError()
43
51
  }
@@ -7,6 +7,7 @@ import {
7
7
  iconChevronRight,
8
8
  IconSvg,
9
9
  responsiveVal,
10
+ sxx,
10
11
  ToggleButton,
11
12
  } from '@graphcommerce/next-ui'
12
13
  import type { UseFormComposeOptions } from '@graphcommerce/react-hook-form'
@@ -83,12 +84,12 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
83
84
  onSubmit={submitHandler}
84
85
  noValidate
85
86
  className={classes.formRoot}
86
- sx={[
87
+ sx={sxx(
87
88
  {
88
89
  padding: '5px 0',
89
90
  },
90
- ...(Array.isArray(sx) ? sx : [sx]),
91
- ]}
91
+ sx,
92
+ )}
92
93
  >
93
94
  <input type='hidden' {...register('code', { required: true })} required />
94
95
  <FormRow className={classes.root} sx={{ position: 'relative', padding: 0 }}>
@@ -101,12 +102,12 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
101
102
  direction='left'
102
103
  className={(classes.buttonRoot, classes.leftButtonRoot)}
103
104
  sx={(theme) => ({
104
- background: theme.palette.background.paper,
105
+ background: theme.vars.palette.background.paper,
105
106
  borderRadius: 0,
106
107
  width: 30,
107
108
  height: responsiveVal(60, 85),
108
109
  boxShadow: 'none',
109
- border: `1px solid ${theme.palette.divider}`,
110
+ border: `1px solid ${theme.vars.palette.divider}`,
110
111
  '&:focus': {
111
112
  boxShadow: 'none',
112
113
  },
@@ -159,16 +160,16 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
159
160
  selected={value === buttonValue}
160
161
  sx={(theme) => ({
161
162
  typography: 'h6',
162
- border: `1px solid ${theme.palette.divider}`,
163
+ border: `1px solid ${theme.vars.palette.divider}`,
163
164
  boxShadow: 'none',
164
165
  transition: 'color .15s ease',
165
166
  whiteSpace: 'nowrap',
166
167
  '&.selected': {
167
- border: `1px solid ${theme.palette.secondary.main}`,
168
- background: `${theme.palette.secondary.main}`,
169
- color: `${theme.palette.secondary.contrastText}`,
168
+ border: `1px solid ${theme.vars.palette.secondary.main}`,
169
+ background: `${theme.vars.palette.secondary.main}`,
170
+ color: `${theme.vars.palette.secondary.contrastText}`,
170
171
  '&:hover': {
171
- background: `${theme.palette.secondary.main}`,
172
+ background: `${theme.vars.palette.secondary.main}`,
172
173
  },
173
174
  },
174
175
  })}
@@ -196,12 +197,12 @@ export function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
196
197
  direction='right'
197
198
  className={`${classes.buttonRoot} ${classes.rightButtonRoot}`}
198
199
  sx={(theme) => ({
199
- background: theme.palette.background.paper,
200
+ background: theme.vars.palette.background.paper,
200
201
  borderRadius: 0,
201
202
  width: 30,
202
203
  height: responsiveVal(60, 85),
203
204
  boxShadow: 'none',
204
- border: `1px solid ${theme.palette.divider}`,
205
+ border: `1px solid ${theme.vars.palette.divider}`,
205
206
  '&:focus': {
206
207
  boxShadow: 'none',
207
208
  },
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": "10.0.0-canary.67",
5
+ "version": "10.0.0-canary.72",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,22 +18,22 @@
18
18
  "./PaymentMethodPlaceOrderNoop/PaymentMethodPlaceOrderNoop": "./PaymentMethodPlaceOrderNoop/PaymentMethodPlaceOrderNoop.tsx"
19
19
  },
20
20
  "peerDependencies": {
21
- "@graphcommerce/ecommerce-ui": "^10.0.0-canary.67",
22
- "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.67",
23
- "@graphcommerce/framer-scroller": "^10.0.0-canary.67",
24
- "@graphcommerce/graphql": "^10.0.0-canary.67",
25
- "@graphcommerce/image": "^10.0.0-canary.67",
26
- "@graphcommerce/magento-cart": "^10.0.0-canary.67",
27
- "@graphcommerce/magento-cart-shipping-address": "^10.0.0-canary.67",
28
- "@graphcommerce/magento-store": "^10.0.0-canary.67",
29
- "@graphcommerce/next-ui": "^10.0.0-canary.67",
30
- "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.67",
31
- "@graphcommerce/react-hook-form": "^10.0.0-canary.67",
32
- "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.67",
21
+ "@graphcommerce/ecommerce-ui": "^10.0.0-canary.72",
22
+ "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.72",
23
+ "@graphcommerce/framer-scroller": "^10.0.0-canary.72",
24
+ "@graphcommerce/graphql": "^10.0.0-canary.72",
25
+ "@graphcommerce/image": "^10.0.0-canary.72",
26
+ "@graphcommerce/magento-cart": "^10.0.0-canary.72",
27
+ "@graphcommerce/magento-cart-shipping-address": "^10.0.0-canary.72",
28
+ "@graphcommerce/magento-store": "^10.0.0-canary.72",
29
+ "@graphcommerce/next-ui": "^10.0.0-canary.72",
30
+ "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.72",
31
+ "@graphcommerce/react-hook-form": "^10.0.0-canary.72",
32
+ "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.72",
33
33
  "@lingui/core": "^5",
34
34
  "@lingui/macro": "^5",
35
35
  "@lingui/react": "^5",
36
- "@mui/material": "^5.10.16",
36
+ "@mui/material": "^7.0.0",
37
37
  "framer-motion": "^11.0.0",
38
38
  "next": "*",
39
39
  "react": "^19.2.0",
@@ -4,10 +4,7 @@ import { fillShippingAddressForm } from '@graphcommerce/magento-cart-shipping-ad
4
4
  import { fillCartAgreementsForm } from '@graphcommerce/magento-cart/test/fillCartAgreementsForm'
5
5
  import type { Page } from '@playwright/test'
6
6
 
7
- export const goToPayment = async (
8
- page: Page,
9
- apolloClient: ApolloClient<NormalizedCacheObject>,
10
- ) => {
7
+ export const goToPayment = async (page: Page, apolloClient: ApolloClient) => {
11
8
  await page.locator('#view-shopping-cart-button').click()
12
9
  await page.locator('#cart-start-checkout').click()
13
10