@graphcommerce/magento-customer 5.1.1 → 5.2.0-canary.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 +6 -0
- package/components/WaitForCustomer/WaitForCustomer.tsx +27 -21
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.2.0-canary.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1769](https://github.com/graphcommerce-org/graphcommerce/pull/1769) [`2693a616a`](https://github.com/graphcommerce-org/graphcommerce/commit/2693a616af2f9793012a5fb2eeacc084e695b83e) - WaitForCustomer now accepts overridable components for the fallback and unauthenticated state. ([@mikekeehnen](https://github.com/mikekeehnen))
|
|
8
|
+
|
|
3
9
|
## 5.1.1
|
|
4
10
|
|
|
5
11
|
## 5.1.1-canary.1
|
|
@@ -3,11 +3,14 @@ import { FullPageMessage, IconSvg, iconPerson } from '@graphcommerce/next-ui'
|
|
|
3
3
|
import { Trans } from '@lingui/react'
|
|
4
4
|
import { Button, CircularProgress } from '@mui/material'
|
|
5
5
|
import PageLink from 'next/link'
|
|
6
|
+
import React from 'react'
|
|
6
7
|
import { useCustomerSession } from '../../hooks/useCustomerSession'
|
|
7
8
|
import { ApolloCustomerErrorFullPage } from '../ApolloCustomerError/ApolloCustomerErrorFullPage'
|
|
8
9
|
|
|
9
10
|
type WaitForCustomerProps = Omit<WaitForQueriesProps, 'fallback' | 'waitFor'> & {
|
|
10
11
|
waitFor?: WaitForQueriesProps['waitFor']
|
|
12
|
+
fallback?: React.ReactNode
|
|
13
|
+
unauthenticated?: React.ReactNode
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export function nonNullable<T>(value: T): value is NonNullable<T> {
|
|
@@ -37,7 +40,7 @@ export function nonNullable<T>(value: T): value is NonNullable<T> {
|
|
|
37
40
|
* ```
|
|
38
41
|
*/
|
|
39
42
|
export function WaitForCustomer(props: WaitForCustomerProps) {
|
|
40
|
-
const { waitFor = [], children } = props
|
|
43
|
+
const { waitFor = [], children, fallback, unauthenticated } = props
|
|
41
44
|
|
|
42
45
|
const session = useCustomerSession()
|
|
43
46
|
const queries = Array.isArray(waitFor) ? waitFor : [waitFor]
|
|
@@ -49,28 +52,31 @@ export function WaitForCustomer(props: WaitForCustomerProps) {
|
|
|
49
52
|
<WaitForQueries
|
|
50
53
|
waitFor={!session.loggedIn ? session.query : queries}
|
|
51
54
|
fallback={
|
|
52
|
-
|
|
53
|
-
<Trans id='
|
|
54
|
-
|
|
55
|
+
fallback ?? (
|
|
56
|
+
<FullPageMessage icon={<CircularProgress />} title={<Trans id='Loading your data' />}>
|
|
57
|
+
<Trans id='This may take a second' />
|
|
58
|
+
</FullPageMessage>
|
|
59
|
+
)
|
|
55
60
|
}
|
|
56
61
|
>
|
|
57
|
-
{!session.loggedIn &&
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
{!session.loggedIn &&
|
|
63
|
+
(unauthenticated ?? (
|
|
64
|
+
<FullPageMessage
|
|
65
|
+
icon={<IconSvg src={iconPerson} size='xxl' />}
|
|
66
|
+
title={<Trans id='You must sign in to continue' />}
|
|
67
|
+
button={
|
|
68
|
+
<PageLink href='/account/signin' passHref>
|
|
69
|
+
<Button variant='pill' color='secondary' size='large'>
|
|
70
|
+
{!session.valid ? (
|
|
71
|
+
<Trans id='Sign in' />
|
|
72
|
+
) : (
|
|
73
|
+
<Trans id='Sign in or create an account!' />
|
|
74
|
+
)}
|
|
75
|
+
</Button>
|
|
76
|
+
</PageLink>
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
))}
|
|
74
80
|
{session.loggedIn && error && <ApolloCustomerErrorFullPage error={error} />}
|
|
75
81
|
{session.loggedIn && !error && children}
|
|
76
82
|
</WaitForQueries>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-customer",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.2.0-canary.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,20 +12,20 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "5.
|
|
16
|
-
"@graphcommerce/prettier-config-pwa": "5.
|
|
17
|
-
"@graphcommerce/typescript-config-pwa": "5.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "5.2.0-canary.0",
|
|
16
|
+
"@graphcommerce/prettier-config-pwa": "5.2.0-canary.0",
|
|
17
|
+
"@graphcommerce/typescript-config-pwa": "5.2.0-canary.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@graphcommerce/ecommerce-ui": "5.
|
|
21
|
-
"@graphcommerce/framer-utils": "5.
|
|
22
|
-
"@graphcommerce/graphql": "5.
|
|
23
|
-
"@graphcommerce/graphql-mesh": "5.
|
|
24
|
-
"@graphcommerce/image": "5.
|
|
25
|
-
"@graphcommerce/magento-graphql": "5.
|
|
26
|
-
"@graphcommerce/magento-store": "5.
|
|
27
|
-
"@graphcommerce/next-ui": "5.
|
|
28
|
-
"@graphcommerce/react-hook-form": "5.
|
|
20
|
+
"@graphcommerce/ecommerce-ui": "5.2.0-canary.0",
|
|
21
|
+
"@graphcommerce/framer-utils": "5.2.0-canary.0",
|
|
22
|
+
"@graphcommerce/graphql": "5.2.0-canary.0",
|
|
23
|
+
"@graphcommerce/graphql-mesh": "5.2.0-canary.0",
|
|
24
|
+
"@graphcommerce/image": "5.2.0-canary.0",
|
|
25
|
+
"@graphcommerce/magento-graphql": "5.2.0-canary.0",
|
|
26
|
+
"@graphcommerce/magento-store": "5.2.0-canary.0",
|
|
27
|
+
"@graphcommerce/next-ui": "5.2.0-canary.0",
|
|
28
|
+
"@graphcommerce/react-hook-form": "5.2.0-canary.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@lingui/react": "^3.13.2",
|