@graphcommerce/magento-customer 4.1.6 → 4.2.2
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 +47 -0
- package/components/ApolloCustomerError/ApolloCustomerErrorSnackbar.tsx +7 -0
- package/components/CustomerFab/CustomerFab.tsx +1 -1
- package/components/SignOutForm/SignOutForm.tsx +4 -0
- package/components/SignUpForm/SignUp.graphql +1 -19
- package/components/SignUpForm/SignUpConfirm.graphql +15 -0
- package/components/SignUpForm/SignUpForm.tsx +28 -9
- package/components/SignUpForm/SignUpFormInline.tsx +14 -2
- package/components/SignUpForm/SignUpMutationFragment.graphql +21 -0
- package/components/index.ts +1 -0
- package/graphql/CustomerStoreConfig.graphql +5 -0
- package/package.json +13 -13
- package/typePolicies.ts +8 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`3c801f45c`](https://github.com/graphcommerce-org/graphcommerce/commit/3c801f45c7df55131acf30ae2fe0d2344830d480), [`3192fab82`](https://github.com/graphcommerce-org/graphcommerce/commit/3192fab82560e2211dfcacadc3b0b305260527d8), [`104abd14e`](https://github.com/graphcommerce-org/graphcommerce/commit/104abd14e1585ef0d8de77937d25156b8fa1e201), [`0e425e85e`](https://github.com/graphcommerce-org/graphcommerce/commit/0e425e85ee8fed280349317ee0440c7bceea5823), [`2a125b1f9`](https://github.com/graphcommerce-org/graphcommerce/commit/2a125b1f98bb9272d96c3577f21d6c984caad892), [`8a354d1cd`](https://github.com/graphcommerce-org/graphcommerce/commit/8a354d1cd4757497ddfc9b1969a0addbc8ff616b)]:
|
|
8
|
+
- @graphcommerce/next-ui@4.6.0
|
|
9
|
+
- @graphcommerce/react-hook-form@3.1.0
|
|
10
|
+
- @graphcommerce/image@3.1.4
|
|
11
|
+
- @graphcommerce/ecommerce-ui@1.0.6
|
|
12
|
+
- @graphcommerce/magento-store@4.1.6
|
|
13
|
+
|
|
14
|
+
## 4.2.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#1378](https://github.com/graphcommerce-org/graphcommerce/pull/1378) [`b610a6e40`](https://github.com/graphcommerce-org/graphcommerce/commit/b610a6e4049e8c9e8b5d2aeff31b8e1bfc24abe5) Thanks [@paales](https://github.com/paales)! - Pin all versions internally so we can’t end up in an unfixable state for the user
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`b610a6e40`](https://github.com/graphcommerce-org/graphcommerce/commit/b610a6e4049e8c9e8b5d2aeff31b8e1bfc24abe5), [`22ff9df16`](https://github.com/graphcommerce-org/graphcommerce/commit/22ff9df1677742ae8e07d9b7e5b12fbb487580dc)]:
|
|
21
|
+
- @graphcommerce/ecommerce-ui@1.0.5
|
|
22
|
+
- @graphcommerce/graphql@3.0.7
|
|
23
|
+
- @graphcommerce/image@3.1.3
|
|
24
|
+
- @graphcommerce/magento-graphql@3.0.6
|
|
25
|
+
- @graphcommerce/magento-store@4.1.5
|
|
26
|
+
- @graphcommerce/next-ui@4.5.1
|
|
27
|
+
- @graphcommerce/react-hook-form@3.0.7
|
|
28
|
+
|
|
29
|
+
## 4.2.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- [#1368](https://github.com/graphcommerce-org/graphcommerce/pull/1368) [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a) Thanks [@paales](https://github.com/paales)! - Add a feature to set CUSTOMER_REQUIRE_EMAIL_CONFIRMATION in the env
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- [#1369](https://github.com/graphcommerce-org/graphcommerce/pull/1369) [`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9) Thanks [@paales](https://github.com/paales)! - Upgraded dependencies
|
|
38
|
+
|
|
39
|
+
* [#1362](https://github.com/graphcommerce-org/graphcommerce/pull/1362) [`6213f0b0f`](https://github.com/graphcommerce-org/graphcommerce/commit/6213f0b0f5f53d622b993d9f7ea96cbbeb5bd670) Thanks [@timhofman](https://github.com/timhofman)! - persistence layer not purged at logout
|
|
40
|
+
|
|
41
|
+
* Updated dependencies [[`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a), [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a), [`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9), [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a), [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a)]:
|
|
42
|
+
- @graphcommerce/graphql@3.0.6
|
|
43
|
+
- @graphcommerce/next-ui@4.5.0
|
|
44
|
+
- @graphcommerce/ecommerce-ui@1.0.4
|
|
45
|
+
- @graphcommerce/image@3.1.2
|
|
46
|
+
- @graphcommerce/magento-graphql@3.0.5
|
|
47
|
+
- @graphcommerce/magento-store@4.1.4
|
|
48
|
+
- @graphcommerce/react-hook-form@3.0.6
|
|
49
|
+
|
|
3
50
|
## 4.1.6
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ApolloErrorSnackbar, ApolloErrorSnackbarProps } from '@graphcommerce/ecommerce-ui'
|
|
2
|
+
|
|
3
|
+
type ApolloCustomerErrorSnackbarProps = ApolloErrorSnackbarProps
|
|
4
|
+
|
|
5
|
+
export function ApolloCustomerErrorSnackbar(props: ApolloCustomerErrorSnackbarProps) {
|
|
6
|
+
return <ApolloErrorSnackbar {...props} />
|
|
7
|
+
}
|
|
@@ -31,7 +31,7 @@ function CustomerFabContent(props: CustomerFabContentProps) {
|
|
|
31
31
|
<PageLink href={requireAuth ? guestHref : authHref} passHref>
|
|
32
32
|
<Fab
|
|
33
33
|
color='inherit'
|
|
34
|
-
|
|
34
|
+
id='account'
|
|
35
35
|
aria-label={t`Account`}
|
|
36
36
|
size='large'
|
|
37
37
|
className={classes.root}
|
|
@@ -3,16 +3,20 @@ import { useRouter } from 'next/router'
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
|
|
5
5
|
import { SignOutFormDocument } from './SignOutForm.gql'
|
|
6
|
+
import { useApolloClient } from '@graphcommerce/graphql'
|
|
6
7
|
|
|
7
8
|
type SignOutFormProps = { button: (props: { formState: FormState<unknown> }) => React.ReactNode }
|
|
8
9
|
|
|
9
10
|
export function SignOutForm(props: SignOutFormProps) {
|
|
10
11
|
const { button } = props
|
|
11
12
|
const router = useRouter()
|
|
13
|
+
const client = useApolloClient()
|
|
14
|
+
|
|
12
15
|
const { handleSubmit, formState, error } = useFormGqlMutation(
|
|
13
16
|
SignOutFormDocument,
|
|
14
17
|
{
|
|
15
18
|
onComplete: () => {
|
|
19
|
+
client.clearStore()
|
|
16
20
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
17
21
|
router.push('/')
|
|
18
22
|
},
|
|
@@ -11,25 +11,7 @@ mutation SignUp(
|
|
|
11
11
|
$isSubscribed: Boolean = false
|
|
12
12
|
$dateOfBirth: String
|
|
13
13
|
) {
|
|
14
|
-
|
|
15
|
-
input: {
|
|
16
|
-
email: $email
|
|
17
|
-
password: $password
|
|
18
|
-
prefix: $prefix
|
|
19
|
-
firstname: $firstname
|
|
20
|
-
middlename: $middlename
|
|
21
|
-
lastname: $lastname
|
|
22
|
-
suffix: $suffix
|
|
23
|
-
taxvat: $taxvat
|
|
24
|
-
gender: $gender
|
|
25
|
-
is_subscribed: $isSubscribed
|
|
26
|
-
date_of_birth: $dateOfBirth
|
|
27
|
-
}
|
|
28
|
-
) {
|
|
29
|
-
customer {
|
|
30
|
-
...CustomerInfo
|
|
31
|
-
}
|
|
32
|
-
}
|
|
14
|
+
...CreateCustomerMutationFragment
|
|
33
15
|
generateCustomerToken(email: $email, password: $password) {
|
|
34
16
|
token
|
|
35
17
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
mutation SignUpConfirm(
|
|
2
|
+
$email: String!
|
|
3
|
+
$password: String!
|
|
4
|
+
$prefix: String!
|
|
5
|
+
$firstname: String!
|
|
6
|
+
$middlename: String
|
|
7
|
+
$lastname: String!
|
|
8
|
+
$suffix: String
|
|
9
|
+
$taxvat: String
|
|
10
|
+
$gender: Int
|
|
11
|
+
$isSubscribed: Boolean = false
|
|
12
|
+
$dateOfBirth: String
|
|
13
|
+
) {
|
|
14
|
+
...CreateCustomerMutationFragment
|
|
15
|
+
}
|
|
@@ -1,22 +1,30 @@
|
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
|
1
2
|
import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
|
|
3
|
+
import { StoreConfigDocument } from '@graphcommerce/magento-store'
|
|
2
4
|
import { Button, FormActions, FormRow } from '@graphcommerce/next-ui'
|
|
3
5
|
import { useFormGqlMutation, useFormPersist } from '@graphcommerce/react-hook-form'
|
|
4
6
|
import { t, Trans } from '@lingui/macro'
|
|
5
|
-
import { FormControlLabel, Switch, TextField } from '@mui/material'
|
|
6
|
-
import {
|
|
7
|
+
import { Alert, FormControlLabel, Switch, TextField } from '@mui/material'
|
|
8
|
+
import { ApolloCustomerErrorSnackbar } from '../ApolloCustomerError/ApolloCustomerErrorSnackbar'
|
|
7
9
|
import { NameFields } from '../NameFields/NameFields'
|
|
8
10
|
import { SignUpDocument, SignUpMutation, SignUpMutationVariables } from './SignUp.gql'
|
|
11
|
+
import { SignUpConfirmDocument } from './SignUpConfirm.gql'
|
|
9
12
|
|
|
10
|
-
type SignUpFormProps = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
type SignUpFormProps = { email: string }
|
|
14
|
+
|
|
15
|
+
const requireEmailValidation = process.env.CUSTOMER_REQUIRE_EMAIL_CONFIRMATION === '1'
|
|
13
16
|
|
|
14
17
|
export function SignUpForm(props: SignUpFormProps) {
|
|
15
18
|
const { email } = props
|
|
19
|
+
|
|
20
|
+
const storeConfig = useQuery(StoreConfigDocument).data?.storeConfig
|
|
21
|
+
|
|
22
|
+
const Mutation = requireEmailValidation ? SignUpConfirmDocument : SignUpDocument
|
|
23
|
+
|
|
16
24
|
const form = useFormGqlMutation<
|
|
17
25
|
SignUpMutation,
|
|
18
26
|
SignUpMutationVariables & { confirmPassword?: string }
|
|
19
|
-
>(
|
|
27
|
+
>(Mutation, { defaultValues: { email } }, { errorPolicy: 'all' })
|
|
20
28
|
|
|
21
29
|
const { muiRegister, handleSubmit, required, watch, formState, error } = form
|
|
22
30
|
const [remainingError, inputError] = graphqlErrorByCategory({ category: 'graphql-input', error })
|
|
@@ -26,6 +34,14 @@ export function SignUpForm(props: SignUpFormProps) {
|
|
|
26
34
|
|
|
27
35
|
useFormPersist({ form, name: 'SignUp', exclude: ['password', 'confirmPassword'] })
|
|
28
36
|
|
|
37
|
+
if (requireEmailValidation && form.formState.isSubmitSuccessful) {
|
|
38
|
+
return (
|
|
39
|
+
<Alert>
|
|
40
|
+
<Trans>Please check your inbox to validate your email ({email})</Trans>
|
|
41
|
+
</Alert>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
29
45
|
return (
|
|
30
46
|
<form onSubmit={submitHandler} noValidate>
|
|
31
47
|
<FormRow>
|
|
@@ -39,7 +55,10 @@ export function SignUpForm(props: SignUpFormProps) {
|
|
|
39
55
|
required={required.password}
|
|
40
56
|
{...muiRegister('password', {
|
|
41
57
|
required: required.password,
|
|
42
|
-
minLength: {
|
|
58
|
+
minLength: {
|
|
59
|
+
value: Number(storeConfig?.minimum_password_length ?? 8),
|
|
60
|
+
message: t`Password must have at least 8 characters`,
|
|
61
|
+
},
|
|
43
62
|
})}
|
|
44
63
|
helperText={formState.errors.password?.message || inputError?.message}
|
|
45
64
|
disabled={formState.isSubmitting}
|
|
@@ -69,12 +88,12 @@ export function SignUpForm(props: SignUpFormProps) {
|
|
|
69
88
|
label={<Trans>Subscribe to newsletter</Trans>}
|
|
70
89
|
/>
|
|
71
90
|
|
|
72
|
-
<
|
|
91
|
+
<ApolloCustomerErrorSnackbar error={remainingError} />
|
|
73
92
|
|
|
74
93
|
<FormActions>
|
|
75
94
|
<Button
|
|
76
95
|
type='submit'
|
|
77
|
-
|
|
96
|
+
id='create-account'
|
|
78
97
|
variant='contained'
|
|
79
98
|
color='primary'
|
|
80
99
|
size='large'
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
|
2
|
+
import { StoreConfigDocument } from '@graphcommerce/magento-store'
|
|
1
3
|
import { Button, extendableComponent, Form, FormRow } from '@graphcommerce/next-ui'
|
|
2
4
|
import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
3
|
-
import { Trans } from '@lingui/macro'
|
|
5
|
+
import { t, Trans } from '@lingui/macro'
|
|
4
6
|
import { Box, TextField } from '@mui/material'
|
|
5
7
|
import React, { PropsWithChildren } from 'react'
|
|
6
8
|
import { SignUpMutationVariables, SignUpMutation, SignUpDocument } from './SignUp.gql'
|
|
@@ -42,6 +44,10 @@ export function SignUpFormInline({
|
|
|
42
44
|
const submitHandler = handleSubmit(onSubmitted)
|
|
43
45
|
const watchPassword = watch('password')
|
|
44
46
|
|
|
47
|
+
const minPasswordLength = Number(
|
|
48
|
+
useQuery(StoreConfigDocument).data?.storeConfig?.minimum_password_length ?? 8,
|
|
49
|
+
)
|
|
50
|
+
|
|
45
51
|
return (
|
|
46
52
|
<Form onSubmit={submitHandler} noValidate className={classes.form} sx={{ padding: 0 }}>
|
|
47
53
|
<FormRow key='inline-signup' className={classes.row} sx={{ padding: 0 }}>
|
|
@@ -54,7 +60,13 @@ export function SignUpFormInline({
|
|
|
54
60
|
autoComplete='new-password'
|
|
55
61
|
id='new-password'
|
|
56
62
|
required={required.password}
|
|
57
|
-
{...muiRegister('password', {
|
|
63
|
+
{...muiRegister('password', {
|
|
64
|
+
required: required.password,
|
|
65
|
+
minLength: {
|
|
66
|
+
value: minPasswordLength,
|
|
67
|
+
message: t`Password must have at least 8 characters`,
|
|
68
|
+
},
|
|
69
|
+
})}
|
|
58
70
|
helperText={error?.message}
|
|
59
71
|
disabled={formState.isSubmitting}
|
|
60
72
|
/>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
fragment CreateCustomerMutationFragment on Mutation {
|
|
2
|
+
createCustomer(
|
|
3
|
+
input: {
|
|
4
|
+
email: $email
|
|
5
|
+
password: $password
|
|
6
|
+
prefix: $prefix
|
|
7
|
+
firstname: $firstname
|
|
8
|
+
middlename: $middlename
|
|
9
|
+
lastname: $lastname
|
|
10
|
+
suffix: $suffix
|
|
11
|
+
taxvat: $taxvat
|
|
12
|
+
gender: $gender
|
|
13
|
+
is_subscribed: $isSubscribed
|
|
14
|
+
date_of_birth: $dateOfBirth
|
|
15
|
+
}
|
|
16
|
+
) {
|
|
17
|
+
customer {
|
|
18
|
+
...CustomerInfo
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/components/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './AddressMultiLine/AddressMultiLine'
|
|
|
5
5
|
export * from './AddressSingleLine/AddressSingleLine'
|
|
6
6
|
export * from './ApolloCustomerError/ApolloCustomerErrorAlert'
|
|
7
7
|
export * from './ApolloCustomerError/ApolloCustomerErrorFullPage'
|
|
8
|
+
export * from './ApolloCustomerError/ApolloCustomerErrorSnackbar'
|
|
8
9
|
export * from './ChangeNameForm/ChangeNameForm'
|
|
9
10
|
export * from './ChangePasswordForm/ChangePassword.gql'
|
|
10
11
|
export * from './ChangePasswordForm/ChangePasswordForm'
|
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.2.2",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,25 +12,25 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
16
|
-
"@graphcommerce/prettier-config-pwa": "^4.0.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.4",
|
|
16
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.5",
|
|
17
17
|
"@graphcommerce/typescript-config-pwa": "^4.0.2",
|
|
18
|
-
"@playwright/test": "^1.
|
|
18
|
+
"@playwright/test": "^1.20.1"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@graphcommerce/ecommerce-ui": "
|
|
22
|
-
"@graphcommerce/graphql": "
|
|
23
|
-
"@graphcommerce/image": "
|
|
24
|
-
"@graphcommerce/magento-graphql": "
|
|
25
|
-
"@graphcommerce/magento-store": "
|
|
26
|
-
"@graphcommerce/next-ui": "
|
|
27
|
-
"@graphcommerce/react-hook-form": "
|
|
21
|
+
"@graphcommerce/ecommerce-ui": "1.0.6",
|
|
22
|
+
"@graphcommerce/graphql": "3.0.7",
|
|
23
|
+
"@graphcommerce/image": "3.1.4",
|
|
24
|
+
"@graphcommerce/magento-graphql": "3.0.6",
|
|
25
|
+
"@graphcommerce/magento-store": "4.1.6",
|
|
26
|
+
"@graphcommerce/next-ui": "4.6.0",
|
|
27
|
+
"@graphcommerce/react-hook-form": "3.1.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@lingui/macro": "^3.13.2",
|
|
31
|
-
"@mui/material": "
|
|
31
|
+
"@mui/material": "5.5.3",
|
|
32
32
|
"framer-motion": "^6.2.4",
|
|
33
|
-
"next": "
|
|
33
|
+
"next": "12.1.2",
|
|
34
34
|
"react": "^17.0.2",
|
|
35
35
|
"react-dom": "^17.0.2"
|
|
36
36
|
}
|
package/typePolicies.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FieldPolicy,
|
|
3
|
+
CustomerToken,
|
|
4
|
+
MigrateCache,
|
|
5
|
+
Mutation,
|
|
6
|
+
TypedTypePolicies,
|
|
7
|
+
} from '@graphcommerce/graphql'
|
|
2
8
|
import { CustomerTokenDocument } from './hooks/CustomerToken.gql'
|
|
3
9
|
import { IsEmailAvailableDocument } from './hooks/IsEmailAvailable.gql'
|
|
4
10
|
|
|
5
|
-
const revokeCustomerToken: FieldPolicy<Mutation['revokeCustomerToken']> = {
|
|
6
|
-
merge(_existing, incoming, options) {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
8
|
-
options.cache.reset()
|
|
9
|
-
return incoming
|
|
10
|
-
},
|
|
11
|
-
}
|
|
12
|
-
|
|
13
11
|
const TOKEN_EXPIRATION_MS = 60 * 60 * 1000
|
|
14
12
|
|
|
15
13
|
const valid: FieldPolicy<CustomerToken['valid']> = {
|
|
@@ -74,7 +72,7 @@ const createCustomer: FieldPolicy<Mutation['createCustomer']> = {
|
|
|
74
72
|
|
|
75
73
|
export const customerTypePolicies: TypedTypePolicies = {
|
|
76
74
|
// Query: { fields: { customer } },
|
|
77
|
-
Mutation: { fields: { generateCustomerToken,
|
|
75
|
+
Mutation: { fields: { generateCustomerToken, createCustomer } },
|
|
78
76
|
CustomerToken: { fields: { valid } },
|
|
79
77
|
}
|
|
80
78
|
|