@graphcommerce/magento-cart-payment-method 2.105.8 → 2.106.0

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
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.106.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-payment-method@2.105.11...@graphcommerce/magento-cart-payment-method@2.106.0) (2021-10-04)
7
+
8
+
9
+ ### Features
10
+
11
+ * sort payment methods by availability ([52f5d45](https://github.com/ho-nl/m2-pwa/commit/52f5d450a7a2fdec0c7eea9cd5d48336cb304138))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.105.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-payment-method@2.105.0...@graphcommerce/magento-cart-payment-method@2.105.1) (2021-09-27)
7
18
 
8
19
  **Note:** Version bump only for package @graphcommerce/magento-cart-payment-method
@@ -13,17 +13,16 @@ import { FormControl, makeStyles, Theme } from '@material-ui/core'
13
13
  import clsx from 'clsx'
14
14
  import { m } from 'framer-motion'
15
15
  import React, { useEffect } from 'react'
16
- import { PaymentMethod, PaymentToggleProps } from '../Api/PaymentMethod'
17
16
  import { usePaymentMethodContext } from '../PaymentMethodContext/PaymentMethodContext'
18
17
 
19
- export type PaymentMethodToggleProps = Record<string, unknown>
18
+ export type PaymentMethodTogglesProps = Record<string, unknown>
20
19
 
21
- function Content(props: PaymentMethod) {
22
- const { code } = props
23
- const { modules } = usePaymentMethodContext()
24
- const Component = modules[code]?.PaymentToggle ?? ((p: PaymentToggleProps) => <>{p.title}</>)
25
- return <Component {...props} />
26
- }
20
+ // function Content(props: PaymentMethod) {
21
+ // const { code } = props
22
+ // const { modules } = usePaymentMethodContext()
23
+ // const Component = modules[code]?.PaymentToggle ?? ((p: PaymentToggleProps) => <>{p.title}</>)
24
+ // return <Component {...props} />
25
+ // }
27
26
 
28
27
  const useStyles = makeStyles(
29
28
  (theme: Theme) => ({
@@ -98,10 +97,10 @@ const useStyles = makeStyles(
98
97
  right: 0,
99
98
  },
100
99
  }),
101
- { name: 'PaymentMethodToggle' },
100
+ { name: 'PaymentMethodToggles' },
102
101
  )
103
102
 
104
- export default function PaymentMethodToggle(props: PaymentMethodToggleProps) {
103
+ export default function PaymentMethodToggles(props: PaymentMethodTogglesProps) {
105
104
  const { methods, selectedMethod, setSelectedMethod, setSelectedModule, modules } =
106
105
  usePaymentMethodContext()
107
106
 
@@ -133,6 +132,10 @@ export default function PaymentMethodToggle(props: PaymentMethodToggleProps) {
133
132
 
134
133
  if (!methods || methods.length < 1) return <></>
135
134
 
135
+ const sortedMethods = [...methods].sort((a, b) =>
136
+ !modules?.[a?.code] ? 0 : !modules?.[b?.code] ? -1 : 1,
137
+ )
138
+
136
139
  return (
137
140
  <Form onSubmit={submitHandler} noValidate classes={{ root: classes.formRoot }}>
138
141
  <input type='hidden' {...register('code', { required: true })} required />
@@ -157,7 +160,7 @@ export default function PaymentMethodToggle(props: PaymentMethodToggleProps) {
157
160
  rules={{ required: 'Please select a payment method' }}
158
161
  render={({ field: { onChange, value, name, ref, onBlur } }) => (
159
162
  <Scroller className={classes.scrollerRoot} hideScrollbar>
160
- {methods?.map((pm) => {
163
+ {sortedMethods?.map((pm) => {
161
164
  const buttonValue = `${pm.code}___${pm.child}`
162
165
 
163
166
  return (
package/index.ts CHANGED
@@ -14,5 +14,5 @@ export { default as PaymentMethodOptionsNoop } from './PaymentMethodOptionsNoop/
14
14
  export { default as PaymentMethodPlaceOrder } from './PaymentMethodPlaceOrder/PaymentMethodPlaceOrder'
15
15
  export { default as PaymentMethodPlaceOrderNoop } from './PaymentMethodPlaceOrderNoop/PaymentMethodPlaceOrderNoop'
16
16
 
17
- export * from './PaymentMethodToggle/PaymentMethodToggle'
18
- export { default as PaymentMethodToggle } from './PaymentMethodToggle/PaymentMethodToggle'
17
+ export * from './PaymentMethodToggles/PaymentMethodToggles'
18
+ export { default as PaymentMethodToggle } from './PaymentMethodToggles/PaymentMethodToggles'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-cart-payment-method",
3
- "version": "2.105.8",
3
+ "version": "2.106.0",
4
4
  "sideEffects": false,
5
5
  "engines": {
6
6
  "node": "14.x"
@@ -24,11 +24,12 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@apollo/client": "^3.3.21",
27
+ "@graphcommerce/framer-scroller": "^0.2.5",
27
28
  "@graphcommerce/graphql": "^2.103.4",
28
29
  "@graphcommerce/image": "^2.104.5",
29
- "@graphcommerce/magento-cart": "^3.0.9",
30
- "@graphcommerce/magento-store": "^3.0.7",
31
- "@graphcommerce/next-ui": "^3.0.6",
30
+ "@graphcommerce/magento-cart": "^3.0.13",
31
+ "@graphcommerce/magento-store": "^3.0.11",
32
+ "@graphcommerce/next-ui": "^3.1.3",
32
33
  "@graphcommerce/react-hook-form": "^2.102.4",
33
34
  "@graphql-typed-document-node/core": "^3.1.0",
34
35
  "@material-ui/core": "^4.12.3",
@@ -40,5 +41,5 @@
40
41
  "react-dom": "^17.0.1",
41
42
  "type-fest": "^2.3.4"
42
43
  },
43
- "gitHead": "1cd56a50b55493aff392a0f08830754e9fdc7295"
44
+ "gitHead": "148ed6eb34bf3b3da72c1791c4195d8d141bc6e6"
44
45
  }