@graphcommerce/magento-cart 9.0.0-canary.99 → 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.
- package/CHANGELOG.md +103 -1085
- package/Config.graphqls +7 -0
- package/components/ApolloCartError/ApolloCartErrorAlert.tsx +2 -4
- package/components/ApolloCartError/ApolloCartErrorFullPage.tsx +3 -5
- package/components/ApolloCartError/ApolloCartErrorSnackbar.tsx +2 -4
- package/components/CartAddressMultiLine/CartAddressMultiLine.tsx +1 -1
- package/components/CartAddressSingleLine/CartAddressSingleLine.tsx +2 -1
- package/components/CartAgreementsForm/CartAgreementsForm.tsx +7 -10
- package/components/CartFab/CartFab.tsx +11 -8
- package/components/CartItemSummary/CartItemSummary.tsx +9 -7
- package/components/CartStartCheckout/CartStartCheckout.tsx +4 -3
- package/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx +4 -3
- package/components/CartSummary/CartSummary.tsx +6 -5
- package/components/CartTotals/CartTotals.tsx +5 -4
- package/components/EmptyCart/EmptyCart.tsx +5 -8
- package/components/InlineAccount/InlineAccount.tsx +4 -7
- package/hooks/useAssignCurrentCartId.ts +2 -1
- package/hooks/useCartQuery.ts +4 -8
- package/hooks/useCurrentCartId.ts +4 -6
- package/hooks/useFormGqlMutationCart.ts +4 -8
- package/hooks/useMergeCustomerCart.ts +1 -0
- package/index.ts +0 -1
- package/link/cartLink.ts +8 -5
- package/package.json +16 -16
- package/plugins/CartDebuggerPlugin.tsx +42 -0
- package/plugins/MagentoCartGraphqlProvider.tsx +2 -2
- package/plugins/useSignInFormMergeCart.ts +2 -2
- package/test/fillCartAgreementsForm.ts +2 -2
- package/typePolicies.ts +13 -8
- package/utils/cartPermissions.ts +4 -0
- package/components/CartDebugger/CartDebugger.tsx +0 -30
package/utils/cartPermissions.ts
CHANGED
|
@@ -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
|
-
}
|