@graphcommerce/magento-customer 4.11.7 → 4.12.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 +19 -0
- package/components/SessionDebugger/SessionDebugger.tsx +38 -0
- package/components/SignInForm/SignInForm.tsx +14 -1
- package/components/SignOutForm/SignOutForm.tsx +1 -2
- package/components/WaitForCustomer/WaitForCustomer.tsx +3 -1
- package/hooks/useCustomerSession.ts +4 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1670](https://github.com/graphcommerce-org/graphcommerce/pull/1670) [`8a34f8081`](https://github.com/graphcommerce-org/graphcommerce/commit/8a34f808186274a6fe1d4f309472f1a9c6d00efd) Thanks [@Jessevdpoel](https://github.com/Jessevdpoel)! - Added cache resetting when token expires and logging in with a different account than cached.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#1675](https://github.com/graphcommerce-org/graphcommerce/pull/1675) [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6) Thanks [@paales](https://github.com/paales)! - Added crosssel functionality
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`9e630670f`](https://github.com/graphcommerce-org/graphcommerce/commit/9e630670ff6c952ab7b938d890b5509804985cf3), [`cf3518499`](https://github.com/graphcommerce-org/graphcommerce/commit/cf351849999ad6fe73ce2bb258098a7dd301d517), [`2e9fa5984`](https://github.com/graphcommerce-org/graphcommerce/commit/2e9fa5984a07ff14fc1b3a4f62189a26e8e3ecdd), [`adf13069a`](https://github.com/graphcommerce-org/graphcommerce/commit/adf13069af6460c960276b402237371c12fc6dec), [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6), [`8a34f8081`](https://github.com/graphcommerce-org/graphcommerce/commit/8a34f808186274a6fe1d4f309472f1a9c6d00efd), [`6c2e27b1b`](https://github.com/graphcommerce-org/graphcommerce/commit/6c2e27b1be4aaa888e65a2bd69eaeb467a54a023), [`3dde492ad`](https://github.com/graphcommerce-org/graphcommerce/commit/3dde492ad3a49d96481eeb7453fb305d0017b1a5)]:
|
|
14
|
+
- @graphcommerce/next-ui@4.28.1
|
|
15
|
+
- @graphcommerce/graphql@3.5.0
|
|
16
|
+
- @graphcommerce/framer-utils@3.2.1
|
|
17
|
+
- @graphcommerce/ecommerce-ui@1.5.4
|
|
18
|
+
- @graphcommerce/magento-store@4.3.2
|
|
19
|
+
- @graphcommerce/magento-graphql@3.1.9
|
|
20
|
+
- @graphcommerce/image@3.1.10
|
|
21
|
+
|
|
3
22
|
## 4.11.7
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useApolloClient } from '@graphcommerce/graphql'
|
|
2
|
+
import { CustomerTokenDocument } from '@graphcommerce/magento-customer'
|
|
3
|
+
import { Button } from '@mui/material'
|
|
4
|
+
|
|
5
|
+
export function SessionDebugger() {
|
|
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 currentToken = client.readQuery({ query: CustomerTokenDocument })
|
|
16
|
+
if (!currentToken?.customerToken?.token) {
|
|
17
|
+
console.log('No customerToken available, nothing to break')
|
|
18
|
+
} else {
|
|
19
|
+
console.log(`Changing current token to a random one)`)
|
|
20
|
+
|
|
21
|
+
client.writeQuery({
|
|
22
|
+
query: CustomerTokenDocument,
|
|
23
|
+
data: {
|
|
24
|
+
customerToken: {
|
|
25
|
+
...currentToken?.customerToken,
|
|
26
|
+
valid: false,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
broadcast: true,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
break magento token
|
|
35
|
+
</Button>
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { useApolloClient } from '@graphcommerce/graphql'
|
|
1
2
|
import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
|
|
2
3
|
import { Button, FormRow, FormActions } from '@graphcommerce/next-ui'
|
|
3
4
|
import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
4
5
|
import { Trans } from '@lingui/react'
|
|
5
6
|
import { Box, FormControl, Link, SxProps, TextField, Theme } from '@mui/material'
|
|
6
7
|
import PageLink from 'next/link'
|
|
8
|
+
import { CustomerDocument } from '../../hooks'
|
|
7
9
|
import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
|
|
8
10
|
import { SignInDocument } from './SignIn.gql'
|
|
9
11
|
|
|
@@ -11,9 +13,20 @@ type SignInFormProps = { email: string; sx?: SxProps<Theme> }
|
|
|
11
13
|
|
|
12
14
|
export function SignInForm(props: SignInFormProps) {
|
|
13
15
|
const { email, sx } = props
|
|
16
|
+
|
|
17
|
+
const client = useApolloClient()
|
|
14
18
|
const form = useFormGqlMutation(
|
|
15
19
|
SignInDocument,
|
|
16
|
-
{
|
|
20
|
+
{
|
|
21
|
+
defaultValues: { email },
|
|
22
|
+
onBeforeSubmit: async (values) => {
|
|
23
|
+
const oldEmail = client.cache.readQuery({ query: CustomerDocument })
|
|
24
|
+
if (oldEmail?.customer?.email !== email) {
|
|
25
|
+
await client.resetStore()
|
|
26
|
+
}
|
|
27
|
+
return { ...values, email }
|
|
28
|
+
},
|
|
29
|
+
},
|
|
17
30
|
{ errorPolicy: 'all' },
|
|
18
31
|
)
|
|
19
32
|
|
|
@@ -19,8 +19,7 @@ export function SignOutForm(props: SignOutFormProps) {
|
|
|
19
19
|
{
|
|
20
20
|
onComplete: async () => {
|
|
21
21
|
await client.clearStore()
|
|
22
|
-
|
|
23
|
-
router.push('/')
|
|
22
|
+
await router.push('/')
|
|
24
23
|
},
|
|
25
24
|
},
|
|
26
25
|
{ errorPolicy: 'all' },
|
|
@@ -41,7 +41,9 @@ export function WaitForCustomer(props: WaitForCustomerProps) {
|
|
|
41
41
|
|
|
42
42
|
const session = useCustomerSession()
|
|
43
43
|
const queries = Array.isArray(waitFor) ? waitFor : [waitFor]
|
|
44
|
-
const error = mergeErrors(
|
|
44
|
+
const error = mergeErrors(
|
|
45
|
+
queries.map((query) => (typeof query === 'boolean' ? null : query.error)).filter(nonNullable),
|
|
46
|
+
)
|
|
45
47
|
|
|
46
48
|
return (
|
|
47
49
|
<WaitForQueries
|
|
@@ -34,7 +34,10 @@ export function useCustomerSession(options: UseCustomerSessionOptions = {}) {
|
|
|
34
34
|
* After the initital render we are definitely sure we're not hydrating anymore so we can flip the
|
|
35
35
|
* switch and rerender.
|
|
36
36
|
*/
|
|
37
|
-
useIsomorphicLayoutEffect(() =>
|
|
37
|
+
useIsomorphicLayoutEffect(() => {
|
|
38
|
+
if (!hydrating) return
|
|
39
|
+
startTransition(() => setHydrating(false))
|
|
40
|
+
}, [hydrating])
|
|
38
41
|
|
|
39
42
|
const skip = hydrating
|
|
40
43
|
|
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": "4.
|
|
5
|
+
"version": "4.12.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"type-fest": "^2.12.2"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@graphcommerce/ecommerce-ui": "1.5.
|
|
23
|
-
"@graphcommerce/framer-utils": "3.2.
|
|
24
|
-
"@graphcommerce/graphql": "3.
|
|
22
|
+
"@graphcommerce/ecommerce-ui": "1.5.4",
|
|
23
|
+
"@graphcommerce/framer-utils": "3.2.1",
|
|
24
|
+
"@graphcommerce/graphql": "3.5.0",
|
|
25
25
|
"@graphcommerce/graphql-mesh": "4.2.0",
|
|
26
|
-
"@graphcommerce/image": "3.1.
|
|
27
|
-
"@graphcommerce/magento-graphql": "3.1.
|
|
28
|
-
"@graphcommerce/magento-store": "4.3.
|
|
29
|
-
"@graphcommerce/next-ui": "4.28.
|
|
26
|
+
"@graphcommerce/image": "3.1.10",
|
|
27
|
+
"@graphcommerce/magento-graphql": "3.1.9",
|
|
28
|
+
"@graphcommerce/magento-store": "4.3.2",
|
|
29
|
+
"@graphcommerce/next-ui": "4.28.1",
|
|
30
30
|
"@graphcommerce/react-hook-form": "3.3.5"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|