@graphcommerce/magento-cart 9.0.0-canary.115 → 9.0.0-canary.117

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,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.117
4
+
5
+ ## 9.0.0-canary.116
6
+
3
7
  ## 9.0.0-canary.115
4
8
 
5
9
  ## 9.0.0-canary.114
package/Config.graphqls CHANGED
@@ -30,3 +30,10 @@ extend input GraphCommerceConfig {
30
30
  """
31
31
  cartDisplayPricesInclTax: Boolean
32
32
  }
33
+
34
+ extend input GraphCommerceDebugConfig {
35
+ """
36
+ Enable debugging interface to debug sessions
37
+ """
38
+ cart: Boolean
39
+ }
@@ -5,6 +5,7 @@ import type { CartAddressFragment } from '../CartAddress/CartAddress.gql'
5
5
 
6
6
  export type CartAddressSingleLineProps = CartAddressFragment & { locale?: CountryCodeEnum }
7
7
 
8
+ /** @public */
8
9
  export function CartAddressSingleLine(props: CartAddressSingleLineProps) {
9
10
  const { locale } = props
10
11
  return <AddressSingleLine {...props} country_code={locale} />
@@ -17,14 +17,9 @@ import { useCurrentCartId } from './useCurrentCartId'
17
17
  */
18
18
  export function useCartQuery<Q, V extends { cartId: string; [index: string]: unknown }>(
19
19
  document: TypedDocumentNode<Q, V>,
20
- options: QueryHookOptions<Q, Omit<V, 'cartId'>> & {
21
- /**
22
- * @deprecated Not used anymore, when the cart_id is in the URL, it will always be used.
23
- */
24
- allowUrl?: boolean
25
- } = {},
20
+ options: QueryHookOptions<Q, Omit<V, 'cartId'>> = {},
26
21
  ) {
27
- const { allowUrl, ...queryOptions } = options
22
+ const { ...queryOptions } = options
28
23
 
29
24
  const router = useRouter()
30
25
  const { currentCartId, locked } = useCurrentCartId()
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * @deprecated Is replaced by the useSignInFormMergeCart plugin.
3
+ * @public
3
4
  */
4
5
  export function useMergeCustomerCart() {
5
6
  return null
package/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './Api/CartItemCountChanged.gql'
2
2
  export * from './components'
3
- export * from './components/CartDebugger/CartDebugger'
4
3
  export * from './hooks'
5
4
  export * from './link/cartLink'
6
5
  export * from './typePolicies'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-cart",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.0-canary.115",
5
+ "version": "9.0.0-canary.117",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,20 +12,20 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^9.0.0-canary.115",
16
- "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.115",
17
- "@graphcommerce/framer-next-pages": "^9.0.0-canary.115",
18
- "@graphcommerce/framer-scroller": "^9.0.0-canary.115",
19
- "@graphcommerce/framer-utils": "^9.0.0-canary.115",
20
- "@graphcommerce/graphql": "^9.0.0-canary.115",
21
- "@graphcommerce/image": "^9.0.0-canary.115",
22
- "@graphcommerce/magento-customer": "^9.0.0-canary.115",
23
- "@graphcommerce/magento-graphql": "^9.0.0-canary.115",
24
- "@graphcommerce/magento-store": "^9.0.0-canary.115",
25
- "@graphcommerce/next-ui": "^9.0.0-canary.115",
26
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.115",
27
- "@graphcommerce/react-hook-form": "^9.0.0-canary.115",
28
- "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.115",
15
+ "@graphcommerce/ecommerce-ui": "^9.0.0-canary.117",
16
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.117",
17
+ "@graphcommerce/framer-next-pages": "^9.0.0-canary.117",
18
+ "@graphcommerce/framer-scroller": "^9.0.0-canary.117",
19
+ "@graphcommerce/framer-utils": "^9.0.0-canary.117",
20
+ "@graphcommerce/graphql": "^9.0.0-canary.117",
21
+ "@graphcommerce/image": "^9.0.0-canary.117",
22
+ "@graphcommerce/magento-customer": "^9.0.0-canary.117",
23
+ "@graphcommerce/magento-graphql": "^9.0.0-canary.117",
24
+ "@graphcommerce/magento-store": "^9.0.0-canary.117",
25
+ "@graphcommerce/next-ui": "^9.0.0-canary.117",
26
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.117",
27
+ "@graphcommerce/react-hook-form": "^9.0.0-canary.117",
28
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.117",
29
29
  "@lingui/core": "^4.2.1",
30
30
  "@lingui/macro": "^4.2.1",
31
31
  "@lingui/react": "^4.2.1",
@@ -0,0 +1,42 @@
1
+ import type { PagesProps } from '@graphcommerce/framer-next-pages'
2
+ import { useApolloClient } from '@graphcommerce/graphql/apollo'
3
+ import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
4
+ import { Button } from '@mui/material'
5
+ import { readCartId, writeCartId } from '../hooks/useAssignCurrentCartId'
6
+
7
+ export const config: PluginConfig = {
8
+ type: 'component',
9
+ module: '@graphcommerce/framer-next-pages',
10
+ ifConfig: 'debug.cart',
11
+ }
12
+
13
+ export function FramerNextPages(props: PluginProps<PagesProps>) {
14
+ const { Prev, ...rest } = props
15
+ const client = useApolloClient()
16
+
17
+ return (
18
+ <>
19
+ <Prev {...rest} />
20
+ <div style={{ position: 'fixed', bottom: 20, right: 0, zIndex: 1, opacity: 0.3 }}>
21
+ <Button
22
+ type='button'
23
+ variant='text'
24
+ size='small'
25
+ onClick={() => {
26
+ const currentCartId = readCartId(client.cache)
27
+ if (!currentCartId) {
28
+ // eslint-disable-next-line no-console
29
+ console.log('No customerToken available, nothing to break')
30
+ } else {
31
+ // eslint-disable-next-line no-console
32
+ console.log('Changing current token to a random one')
33
+ writeCartId(client.cache, `${Math.random().toString(36).slice(2)}random-cardId`)
34
+ }
35
+ }}
36
+ >
37
+ break cart token
38
+ </Button>
39
+ </div>
40
+ </>
41
+ )
42
+ }
@@ -1,5 +1,6 @@
1
1
  import { storefrontConfig } from '@graphcommerce/next-ui'
2
2
 
3
+ /** @public */
3
4
  function getCartPermissions(locale: string | undefined) {
4
5
  return (
5
6
  storefrontConfig(locale)?.permissions?.cart ??
@@ -8,14 +9,17 @@ function getCartPermissions(locale: string | undefined) {
8
9
  )
9
10
  }
10
11
 
12
+ /** @public */
11
13
  export function getCartDisabled(locale: string | undefined) {
12
14
  return getCartPermissions(locale) === 'DISABLED'
13
15
  }
14
16
 
17
+ /** @public */
15
18
  export function getCartGuestEnabled(locale: string | undefined) {
16
19
  return getCartPermissions(locale) === 'ENABLED'
17
20
  }
18
21
 
22
+ /** @public */
19
23
  export function getCartEnabledForUser(locale: string | undefined, loggedIn: () => boolean) {
20
24
  if (getCartGuestEnabled(locale)) return true
21
25
  if (getCartDisabled(locale)) return false
@@ -1,30 +0,0 @@
1
- import { useApolloClient } from '@graphcommerce/graphql'
2
- import { Button } from '@mui/material'
3
- import { readCartId, writeCartId } from '../../hooks'
4
-
5
- export function CartDebugger() {
6
- const client = useApolloClient()
7
-
8
- return (
9
- <div style={{ position: 'fixed', bottom: 0, right: 0, zIndex: 1, opacity: 0.3 }}>
10
- <Button
11
- type='button'
12
- variant='text'
13
- size='small'
14
- onClick={() => {
15
- const currentCartId = readCartId(client.cache)
16
- if (!currentCartId) {
17
- // eslint-disable-next-line no-console
18
- console.log('No customerToken available, nothing to break')
19
- } else {
20
- // eslint-disable-next-line no-console
21
- console.log('Changing current token to a random one')
22
- writeCartId(client.cache, `${Math.random().toString(36).slice(2)}random-cardId`)
23
- }
24
- }}
25
- >
26
- break cart
27
- </Button>
28
- </div>
29
- )
30
- }