@graphcommerce/ecommerce-ui 8.0.0-canary.40 → 8.0.0-canary.69
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 +60 -10
- package/components/ApolloError/ApolloErrorAlert.tsx +3 -1
- package/components/ApolloError/ApolloErrorFullPage.tsx +3 -2
- package/components/ApolloError/ApolloErrorSnackbar.tsx +2 -1
- package/components/ApolloError/maskNetworkError.tsx +26 -0
- package/components/WaitForQueries/WaitForQueries.tsx +6 -3
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
1
|
# @graphcommerce/ecommerce-ui
|
|
2
2
|
|
|
3
|
-
## 8.0.0-canary.
|
|
3
|
+
## 8.0.0-canary.69
|
|
4
4
|
|
|
5
|
-
## 7.1.0-canary.
|
|
5
|
+
## 7.1.0-canary.68
|
|
6
|
+
|
|
7
|
+
## 7.1.0-canary.67
|
|
8
|
+
|
|
9
|
+
## 7.1.0-canary.66
|
|
10
|
+
|
|
11
|
+
## 7.1.0-canary.65
|
|
12
|
+
|
|
13
|
+
## 7.1.0-canary.64
|
|
14
|
+
|
|
15
|
+
## 7.1.0-canary.63
|
|
16
|
+
|
|
17
|
+
## 7.1.0-canary.62
|
|
18
|
+
|
|
19
|
+
## 7.1.0-canary.61
|
|
20
|
+
|
|
21
|
+
## 7.1.0-canary.60
|
|
22
|
+
|
|
23
|
+
## 7.1.0-canary.59
|
|
24
|
+
|
|
25
|
+
## 7.1.0-canary.58
|
|
26
|
+
|
|
27
|
+
## 7.1.0-canary.57
|
|
28
|
+
|
|
29
|
+
## 7.1.0-canary.56
|
|
30
|
+
|
|
31
|
+
## 7.1.0-canary.55
|
|
32
|
+
|
|
33
|
+
## 7.1.0-canary.54
|
|
34
|
+
|
|
35
|
+
## 7.1.0-canary.53
|
|
36
|
+
|
|
37
|
+
## 7.1.0-canary.52
|
|
38
|
+
|
|
39
|
+
## 7.1.0-canary.51
|
|
40
|
+
|
|
41
|
+
## 7.1.0-canary.50
|
|
42
|
+
|
|
43
|
+
## 7.1.0-canary.49
|
|
44
|
+
|
|
45
|
+
## 7.1.0-canary.48
|
|
46
|
+
|
|
47
|
+
## 7.1.0-canary.47
|
|
48
|
+
|
|
49
|
+
### Minor Changes
|
|
50
|
+
|
|
51
|
+
- [#2111](https://github.com/graphcommerce-org/graphcommerce/pull/2111) [`35f3d3eaf`](https://github.com/graphcommerce-org/graphcommerce/commit/35f3d3eaf46f4b782bb1149e0efb0ec3819442d6) - Only show network errors in development mode. ([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
52
|
+
|
|
53
|
+
## 7.1.0-canary.46
|
|
54
|
+
|
|
55
|
+
## 7.1.0-canary.45
|
|
6
56
|
|
|
7
57
|
## 7.1.0-canary.38
|
|
8
58
|
|
|
@@ -1026,31 +1076,31 @@
|
|
|
1026
1076
|
All occurences of `<Trans>` and `t` need to be replaced:
|
|
1027
1077
|
|
|
1028
1078
|
```tsx
|
|
1029
|
-
import { Trans, t } from
|
|
1079
|
+
import { Trans, t } from "@lingui/macro";
|
|
1030
1080
|
|
|
1031
1081
|
function MyComponent() {
|
|
1032
|
-
const foo =
|
|
1082
|
+
const foo = "bar";
|
|
1033
1083
|
return (
|
|
1034
1084
|
<div aria-label={t`Account ${foo}`}>
|
|
1035
1085
|
<Trans>My Translation {foo}</Trans>
|
|
1036
1086
|
</div>
|
|
1037
|
-
)
|
|
1087
|
+
);
|
|
1038
1088
|
}
|
|
1039
1089
|
```
|
|
1040
1090
|
|
|
1041
1091
|
Needs to be replaced with:
|
|
1042
1092
|
|
|
1043
1093
|
```tsx
|
|
1044
|
-
import { Trans } from
|
|
1045
|
-
import { i18n } from
|
|
1094
|
+
import { Trans } from "@lingui/react";
|
|
1095
|
+
import { i18n } from "@lingui/core";
|
|
1046
1096
|
|
|
1047
1097
|
function MyComponent() {
|
|
1048
|
-
const foo =
|
|
1098
|
+
const foo = "bar";
|
|
1049
1099
|
return (
|
|
1050
1100
|
<div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
|
|
1051
|
-
<Trans key=
|
|
1101
|
+
<Trans key="My Translation {foo}" values={{ foo }}></Trans>
|
|
1052
1102
|
</div>
|
|
1053
|
-
)
|
|
1103
|
+
);
|
|
1054
1104
|
}
|
|
1055
1105
|
```
|
|
1056
1106
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ApolloError } from '@graphcommerce/graphql'
|
|
2
2
|
import { extendableComponent } from '@graphcommerce/next-ui/Styles/extendableComponent'
|
|
3
|
+
import { Trans } from '@lingui/react'
|
|
3
4
|
import { AlertProps, Alert, Box, SxProps, Theme } from '@mui/material'
|
|
5
|
+
import { maskNetworkError } from './maskNetworkError'
|
|
4
6
|
|
|
5
7
|
const { classes, selectors } = extendableComponent('ApolloErrorAlert', ['root', 'alert'] as const)
|
|
6
8
|
|
|
@@ -46,7 +48,7 @@ export function ApolloErrorAlert(props: ApolloErrorAlertProps) {
|
|
|
46
48
|
key='networkError'
|
|
47
49
|
>
|
|
48
50
|
<Alert severity='error' {...networkErrorAlertProps}>
|
|
49
|
-
|
|
51
|
+
{maskNetworkError(error.networkError)}
|
|
50
52
|
</Alert>
|
|
51
53
|
</Box>
|
|
52
54
|
</Box>
|
|
@@ -3,6 +3,7 @@ import { FullPageMessage, FullPageMessageProps } from '@graphcommerce/next-ui'
|
|
|
3
3
|
import { Trans } from '@lingui/react'
|
|
4
4
|
import { AlertProps } from '@mui/material'
|
|
5
5
|
import { ApolloErrorAlert } from './ApolloErrorAlert'
|
|
6
|
+
import { maskNetworkError } from './maskNetworkError'
|
|
6
7
|
|
|
7
8
|
export type ApolloErrorFullPageProps = {
|
|
8
9
|
error: ApolloError
|
|
@@ -19,14 +20,14 @@ export function ApolloErrorFullPage(props: ApolloErrorFullPageProps) {
|
|
|
19
20
|
...fullPageMessageProps
|
|
20
21
|
} = props
|
|
21
22
|
|
|
22
|
-
const errorCount = error?.graphQLErrors?.length ?? +(error?.networkError ? 1 : 0)
|
|
23
|
+
const errorCount = (error?.graphQLErrors?.length ?? 0) + (error?.networkError ? 1 : 0)
|
|
23
24
|
|
|
24
25
|
if (errorCount === 0) return null
|
|
25
26
|
|
|
26
27
|
if (errorCount === 1) {
|
|
27
28
|
return (
|
|
28
29
|
<FullPageMessage
|
|
29
|
-
title={error?.graphQLErrors[0]
|
|
30
|
+
title={error?.graphQLErrors?.[0]?.message ?? maskNetworkError(error.networkError)}
|
|
30
31
|
{...fullPageMessageProps}
|
|
31
32
|
>
|
|
32
33
|
{children}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ApolloError } from '@graphcommerce/graphql'
|
|
2
2
|
import { ErrorSnackbar, ErrorSnackbarProps } from '@graphcommerce/next-ui'
|
|
3
|
+
import { maskNetworkError } from './maskNetworkError'
|
|
3
4
|
|
|
4
5
|
export type ApolloErrorSnackbarProps = {
|
|
5
6
|
error?: ApolloError
|
|
@@ -14,7 +15,7 @@ export function ApolloErrorSnackbar(props: ApolloErrorSnackbarProps) {
|
|
|
14
15
|
<ErrorSnackbar variant='pill' severity='error' {...passedProps} open={!!error}>
|
|
15
16
|
<>
|
|
16
17
|
{error.graphQLErrors.map((e) => e.message).join(', ')}
|
|
17
|
-
{error.networkError
|
|
18
|
+
{maskNetworkError(error.networkError)}
|
|
18
19
|
</>
|
|
19
20
|
</ErrorSnackbar>
|
|
20
21
|
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ServerError, ServerParseError } from '@graphcommerce/graphql'
|
|
2
|
+
import { Trans } from '@lingui/react'
|
|
3
|
+
|
|
4
|
+
function isServerError(error: Error | ServerParseError | ServerError | null): error is ServerError {
|
|
5
|
+
return 'name' in (error as ServerError)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function isServerParseError(
|
|
9
|
+
error: Error | ServerParseError | ServerError | null,
|
|
10
|
+
): error is ServerParseError {
|
|
11
|
+
return 'bodyText' in (error as ServerParseError)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function maskNetworkError(networkError: Error | ServerParseError | ServerError | null) {
|
|
15
|
+
if (!networkError) return null
|
|
16
|
+
|
|
17
|
+
if (isServerParseError(networkError) || isServerError(networkError)) {
|
|
18
|
+
return <Trans id='Something went wrong on the server, please try again later.' />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (globalThis.navigator && !globalThis.navigator?.onLine) {
|
|
22
|
+
return <Trans id='It appears you are offline, please try again later.' />
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return <Trans id='Something went wrong' />
|
|
26
|
+
}
|
|
@@ -3,18 +3,21 @@ import React, { startTransition, useEffect, useState } from 'react'
|
|
|
3
3
|
|
|
4
4
|
export type WaitForQueriesProps = {
|
|
5
5
|
waitFor: QueryResult<any, any> | boolean | (QueryResult<any, any> | boolean)[] | undefined
|
|
6
|
+
noSsr?: boolean
|
|
6
7
|
children: React.ReactNode
|
|
7
8
|
fallback?: React.ReactNode
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
/** Shows the fallback during: SSR, Hydration and Query Loading. */
|
|
11
12
|
export const WaitForQueries = (props: WaitForQueriesProps) => {
|
|
12
|
-
const { waitFor, fallback, children } = props
|
|
13
|
+
const { waitFor, fallback, children, noSsr = false } = props
|
|
13
14
|
|
|
14
15
|
// Make sure the first render is always the same as the server.
|
|
15
16
|
// Make sure we we use startTransition to make sure we don't get into trouble with Suspense.
|
|
16
|
-
const [mounted, setMounted] = useState(
|
|
17
|
-
useEffect(() =>
|
|
17
|
+
const [mounted, setMounted] = useState(!noSsr)
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (noSsr) startTransition(() => setMounted(true))
|
|
20
|
+
}, [noSsr])
|
|
18
21
|
|
|
19
22
|
// We are done when all queries either have data or an error.
|
|
20
23
|
const isDone = (Array.isArray(waitFor) ? waitFor : [waitFor]).every((res) => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/ecommerce-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "8.0.0-canary.
|
|
5
|
+
"version": "8.0.0-canary.69",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "8.0.0-canary.
|
|
16
|
-
"@graphcommerce/graphql": "8.0.0-canary.
|
|
17
|
-
"@graphcommerce/next-ui": "8.0.0-canary.
|
|
18
|
-
"@graphcommerce/prettier-config-pwa": "8.0.0-canary.
|
|
19
|
-
"@graphcommerce/react-hook-form": "8.0.0-canary.
|
|
20
|
-
"@graphcommerce/typescript-config-pwa": "8.0.0-canary.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^8.0.0-canary.69",
|
|
16
|
+
"@graphcommerce/graphql": "^8.0.0-canary.69",
|
|
17
|
+
"@graphcommerce/next-ui": "^8.0.0-canary.69",
|
|
18
|
+
"@graphcommerce/prettier-config-pwa": "^8.0.0-canary.69",
|
|
19
|
+
"@graphcommerce/react-hook-form": "^8.0.0-canary.69",
|
|
20
|
+
"@graphcommerce/typescript-config-pwa": "^8.0.0-canary.69",
|
|
21
21
|
"@lingui/core": "^4.2.1",
|
|
22
22
|
"@lingui/macro": "^4.2.1",
|
|
23
23
|
"@lingui/react": "^4.2.1",
|