@graphcommerce/magento-cart 9.0.0-canary.98 → 9.0.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +103 -1083
  2. package/Config.graphqls +7 -0
  3. package/components/ApolloCartError/ApolloCartErrorAlert.tsx +2 -4
  4. package/components/ApolloCartError/ApolloCartErrorFullPage.tsx +3 -5
  5. package/components/ApolloCartError/ApolloCartErrorSnackbar.tsx +2 -4
  6. package/components/CartAddressMultiLine/CartAddressMultiLine.tsx +1 -1
  7. package/components/CartAddressSingleLine/CartAddressSingleLine.tsx +2 -1
  8. package/components/CartAgreementsForm/CartAgreementsForm.tsx +7 -10
  9. package/components/CartFab/CartFab.tsx +11 -8
  10. package/components/CartItemSummary/CartItemSummary.tsx +9 -7
  11. package/components/CartStartCheckout/CartStartCheckout.tsx +4 -3
  12. package/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx +4 -3
  13. package/components/CartSummary/CartSummary.tsx +6 -5
  14. package/components/CartTotals/CartTotals.tsx +5 -4
  15. package/components/EmptyCart/EmptyCart.tsx +5 -8
  16. package/components/InlineAccount/InlineAccount.tsx +4 -7
  17. package/hooks/useAssignCurrentCartId.ts +2 -1
  18. package/hooks/useCartQuery.ts +4 -8
  19. package/hooks/useCurrentCartId.ts +4 -6
  20. package/hooks/useFormGqlMutationCart.ts +4 -8
  21. package/hooks/useMergeCustomerCart.ts +1 -0
  22. package/index.ts +0 -1
  23. package/link/cartLink.ts +8 -5
  24. package/package.json +16 -16
  25. package/plugins/CartDebuggerPlugin.tsx +42 -0
  26. package/plugins/MagentoCartGraphqlProvider.tsx +2 -2
  27. package/plugins/useSignInFormMergeCart.ts +2 -2
  28. package/test/fillCartAgreementsForm.ts +2 -2
  29. package/typePolicies.ts +13 -8
  30. package/utils/cartPermissions.ts +4 -0
  31. package/components/CartDebugger/CartDebugger.tsx +0 -30
@@ -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
- }