@graphcommerce/magento-customer 3.6.44 → 4.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 +373 -261
- package/components/AccountAddress/index.tsx +38 -42
- package/components/AccountAddresses/index.tsx +46 -41
- package/components/AddressFields/index.tsx +2 -2
- package/components/AddressMultiLine/index.tsx +8 -6
- package/components/ApolloCustomerError/ApolloCustomerErrorAlert.tsx +2 -2
- package/components/ApolloCustomerError/ApolloCustomerErrorFullPage.tsx +3 -5
- package/components/ChangeNameForm/index.tsx +1 -2
- package/components/ChangePasswordForm/ChangePasswordForm.tsx +2 -4
- package/components/CreateCustomerAddressForm/index.tsx +3 -4
- package/components/CustomerFab/index.tsx +21 -16
- package/components/CustomerMenuFabItem/index.tsx +12 -28
- package/components/DeleteCustomerAddressForm/index.tsx +1 -1
- package/components/EditAddressForm/index.tsx +6 -17
- package/components/ForgotPasswordForm/ForgotPasswordForm.tsx +12 -17
- package/components/NameFields/index.tsx +1 -1
- package/components/ResetPasswordForm/index.tsx +1 -1
- package/components/SignInForm/SignInForm.tsx +7 -21
- package/components/SignInForm/SignInFormInline.tsx +35 -29
- package/components/SignUpForm/SignUpForm.tsx +1 -2
- package/components/SignUpForm/SignUpFormInline.tsx +25 -35
- package/components/UpdateCustomerEmailForm/index.tsx +1 -2
- package/components/UpdateDefaultAddressForm/index.tsx +3 -8
- package/hooks/useExtractCustomerErrors.tsx +1 -1
- package/hooks/useFormIsEmailAvailable.tsx +1 -1
- package/index.ts +1 -3
- package/link/{createAuthLink.ts → createCustomerTokenLink.ts} +2 -3
- package/package.json +16 -24
- package/typePolicies.ts +1 -1
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
1
|
import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
|
|
3
|
-
import {
|
|
2
|
+
import { Button, FormRow, FormActions } from '@graphcommerce/next-ui'
|
|
4
3
|
import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
5
4
|
import { Trans } from '@lingui/macro'
|
|
6
|
-
import { FormControl, Link,
|
|
7
|
-
import { Alert } from '@material-ui/lab'
|
|
5
|
+
import { Box, FormControl, Link, SxProps, TextField, Theme } from '@mui/material'
|
|
8
6
|
import PageLink from 'next/link'
|
|
9
|
-
import React from 'react'
|
|
10
|
-
import { CustomerTokenDocument } from '../../hooks'
|
|
11
7
|
import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
|
|
12
8
|
import { SignInDocument } from './SignIn.gql'
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
forgotPass: {
|
|
17
|
-
whiteSpace: 'nowrap',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{ name: 'SignIn' },
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
type SignInFormProps = { email: string }
|
|
10
|
+
type SignInFormProps = { email: string; sx?: SxProps<Theme> }
|
|
24
11
|
|
|
25
12
|
export default function SignInForm(props: SignInFormProps) {
|
|
26
|
-
const { email } = props
|
|
27
|
-
const classes = useStyles()
|
|
13
|
+
const { email, sx } = props
|
|
28
14
|
const form = useFormGqlMutation(
|
|
29
15
|
SignInDocument,
|
|
30
16
|
{ defaultValues: { email } },
|
|
@@ -39,7 +25,7 @@ export default function SignInForm(props: SignInFormProps) {
|
|
|
39
25
|
const submitHandler = handleSubmit(() => {})
|
|
40
26
|
|
|
41
27
|
return (
|
|
42
|
-
<form onSubmit={submitHandler} noValidate>
|
|
28
|
+
<Box component='form' onSubmit={submitHandler} noValidate sx={sx}>
|
|
43
29
|
<FormRow>
|
|
44
30
|
<TextField
|
|
45
31
|
key='password'
|
|
@@ -55,7 +41,7 @@ export default function SignInForm(props: SignInFormProps) {
|
|
|
55
41
|
InputProps={{
|
|
56
42
|
endAdornment: (
|
|
57
43
|
<PageLink href='/account/forgot-password' key='forgot-password' passHref>
|
|
58
|
-
<Link
|
|
44
|
+
<Link underline='hover' sx={{ whiteSpace: 'nowrap' }}>
|
|
59
45
|
<Trans>Forgot password?</Trans>
|
|
60
46
|
</Link>
|
|
61
47
|
</PageLink>
|
|
@@ -81,6 +67,6 @@ export default function SignInForm(props: SignInFormProps) {
|
|
|
81
67
|
</Button>
|
|
82
68
|
</FormControl>
|
|
83
69
|
</FormActions>
|
|
84
|
-
</
|
|
70
|
+
</Box>
|
|
85
71
|
)
|
|
86
72
|
}
|
|
@@ -1,34 +1,17 @@
|
|
|
1
|
-
import { Button } from '@graphcommerce/next-ui'
|
|
1
|
+
import { Button, extendableComponent } from '@graphcommerce/next-ui'
|
|
2
2
|
import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
3
3
|
import { Trans } from '@lingui/macro'
|
|
4
|
-
import {
|
|
4
|
+
import { Box, SxProps, TextField, Theme } from '@mui/material'
|
|
5
5
|
import PageLink from 'next/link'
|
|
6
|
-
import
|
|
6
|
+
import { PropsWithChildren } from 'react'
|
|
7
7
|
import { SignInDocument, SignInMutationVariables } from './SignIn.gql'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
(theme: Theme) => ({
|
|
11
|
-
form: {
|
|
12
|
-
display: 'grid',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
gridRowGap: theme.spacings.sm,
|
|
15
|
-
gridColumnGap: theme.spacings.xs,
|
|
16
|
-
gridTemplateColumns: '1fr',
|
|
17
|
-
[theme.breakpoints.up('sm')]: {
|
|
18
|
-
gridTemplateColumns: '5fr 1fr',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
button: {
|
|
22
|
-
minWidth: 'max-content',
|
|
23
|
-
},
|
|
24
|
-
}),
|
|
25
|
-
{ name: 'SignInFormInline' },
|
|
26
|
-
)
|
|
9
|
+
type InlineSignInFormProps = Omit<SignInMutationVariables, 'password'> & { sx?: SxProps<Theme> }
|
|
27
10
|
|
|
28
|
-
|
|
11
|
+
const { classes } = extendableComponent('SignInFormInline', ['form', 'button'] as const)
|
|
29
12
|
|
|
30
|
-
export default function SignInFormInline(
|
|
31
|
-
const
|
|
13
|
+
export default function SignInFormInline(props: PropsWithChildren<InlineSignInFormProps>) {
|
|
14
|
+
const { email, sx = [] } = props
|
|
32
15
|
const form = useFormGqlMutation(
|
|
33
16
|
SignInDocument,
|
|
34
17
|
{ defaultValues: { email } },
|
|
@@ -38,7 +21,25 @@ export default function SignInFormInline({ email }: PropsWithChildren<InlineSign
|
|
|
38
21
|
const submitHandler = handleSubmit(() => {})
|
|
39
22
|
|
|
40
23
|
return (
|
|
41
|
-
<
|
|
24
|
+
<Box
|
|
25
|
+
component='form'
|
|
26
|
+
onSubmit={submitHandler}
|
|
27
|
+
noValidate
|
|
28
|
+
className={classes.form}
|
|
29
|
+
sx={[
|
|
30
|
+
(theme) => ({
|
|
31
|
+
display: 'grid',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
gridRowGap: theme.spacings.sm,
|
|
34
|
+
gridColumnGap: theme.spacings.xs,
|
|
35
|
+
gridTemplateColumns: '1fr',
|
|
36
|
+
[theme.breakpoints.up('sm')]: {
|
|
37
|
+
gridTemplateColumns: '5fr 1fr',
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
41
|
+
]}
|
|
42
|
+
>
|
|
42
43
|
<TextField
|
|
43
44
|
variant='outlined'
|
|
44
45
|
type='password'
|
|
@@ -54,16 +55,21 @@ export default function SignInFormInline({ email }: PropsWithChildren<InlineSign
|
|
|
54
55
|
InputProps={{
|
|
55
56
|
endAdornment: (
|
|
56
57
|
<PageLink href='/account/forgot-password' key='forgot-password' passHref>
|
|
57
|
-
<Button
|
|
58
|
-
|
|
58
|
+
<Button
|
|
59
|
+
color='secondary'
|
|
60
|
+
variant='text'
|
|
61
|
+
className={classes.button}
|
|
62
|
+
sx={{ minWidth: 'max-content' }}
|
|
63
|
+
>
|
|
64
|
+
<Trans>Forgot password?</Trans>
|
|
59
65
|
</Button>
|
|
60
66
|
</PageLink>
|
|
61
67
|
),
|
|
62
68
|
}}
|
|
63
69
|
/>
|
|
64
70
|
<Button type='submit' loading={formState.isSubmitting} color='secondary' variant='pill'>
|
|
65
|
-
Sign in
|
|
71
|
+
<Trans>Sign in</Trans>
|
|
66
72
|
</Button>
|
|
67
|
-
</
|
|
73
|
+
</Box>
|
|
68
74
|
)
|
|
69
75
|
}
|
|
@@ -2,8 +2,7 @@ import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
|
|
|
2
2
|
import { Button, FormActions, FormRow } from '@graphcommerce/next-ui'
|
|
3
3
|
import { useFormGqlMutation, useFormPersist } from '@graphcommerce/react-hook-form'
|
|
4
4
|
import { t, Trans } from '@lingui/macro'
|
|
5
|
-
import { FormControlLabel, Switch, TextField } from '@material
|
|
6
|
-
import React from 'react'
|
|
5
|
+
import { FormControlLabel, Switch, TextField } from '@mui/material'
|
|
7
6
|
import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
|
|
8
7
|
import NameFields from '../NameFields'
|
|
9
8
|
import { SignUpDocument, SignUpMutation, SignUpMutationVariables } from './SignUp.gql'
|
|
@@ -1,49 +1,31 @@
|
|
|
1
|
-
import { Button, Form, FormRow } from '@graphcommerce/next-ui'
|
|
1
|
+
import { Button, extendableComponent, Form, FormRow } from '@graphcommerce/next-ui'
|
|
2
2
|
import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
3
3
|
import { Trans } from '@lingui/macro'
|
|
4
|
-
import {
|
|
4
|
+
import { Box, TextField } from '@mui/material'
|
|
5
5
|
import React, { PropsWithChildren } from 'react'
|
|
6
6
|
import { SignUpMutationVariables, SignUpMutation, SignUpDocument } from './SignUp.gql'
|
|
7
7
|
|
|
8
|
-
const useStyles = makeStyles(
|
|
9
|
-
(theme: Theme) => ({
|
|
10
|
-
buttonFormRow: {
|
|
11
|
-
padding: 0,
|
|
12
|
-
[theme.breakpoints.up('sm')]: {
|
|
13
|
-
gridTemplateColumns: 'minmax(200px, 3.5fr) 1fr',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
form: {
|
|
17
|
-
padding: 0,
|
|
18
|
-
},
|
|
19
|
-
row: {
|
|
20
|
-
padding: 0,
|
|
21
|
-
},
|
|
22
|
-
button: {
|
|
23
|
-
minWidth: 'max-content',
|
|
24
|
-
},
|
|
25
|
-
buttonContainer: {
|
|
26
|
-
alignSelf: 'center',
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
{ name: 'SignUpFormInline' },
|
|
30
|
-
)
|
|
31
|
-
|
|
32
8
|
type SignUpFormInlineProps = Pick<SignUpMutationVariables, 'email'> & {
|
|
33
|
-
|
|
9
|
+
children?: React.ReactNode
|
|
34
10
|
firstname?: string
|
|
35
11
|
lastname?: string
|
|
36
12
|
onSubmitted?: () => void
|
|
37
13
|
}
|
|
38
14
|
|
|
15
|
+
const { classes } = extendableComponent('SignUpFormInline', [
|
|
16
|
+
'form',
|
|
17
|
+
'buttonFormRow',
|
|
18
|
+
'row',
|
|
19
|
+
'buttonContainer',
|
|
20
|
+
] as const)
|
|
21
|
+
|
|
39
22
|
export default function SignUpFormInline({
|
|
40
23
|
email,
|
|
41
|
-
|
|
24
|
+
children,
|
|
42
25
|
firstname,
|
|
43
26
|
lastname,
|
|
44
27
|
onSubmitted = () => {},
|
|
45
28
|
}: PropsWithChildren<SignUpFormInlineProps>) {
|
|
46
|
-
const classes = useStyles()
|
|
47
29
|
const form = useFormGqlMutation<
|
|
48
30
|
SignUpMutation,
|
|
49
31
|
SignUpMutationVariables & { confirmPassword?: string }
|
|
@@ -61,8 +43,8 @@ export default function SignUpFormInline({
|
|
|
61
43
|
const watchPassword = watch('password')
|
|
62
44
|
|
|
63
45
|
return (
|
|
64
|
-
<Form onSubmit={submitHandler} noValidate classes={{
|
|
65
|
-
<FormRow key='inline-signup' classes={{
|
|
46
|
+
<Form onSubmit={submitHandler} noValidate className={classes.form} sx={{ padding: 0 }}>
|
|
47
|
+
<FormRow key='inline-signup' className={classes.row} sx={{ padding: 0 }}>
|
|
66
48
|
<TextField
|
|
67
49
|
variant='outlined'
|
|
68
50
|
type='password'
|
|
@@ -93,9 +75,17 @@ export default function SignUpFormInline({
|
|
|
93
75
|
</FormRow>
|
|
94
76
|
|
|
95
77
|
<FormRow key='signup-submit'>
|
|
96
|
-
<FormRow
|
|
97
|
-
|
|
98
|
-
|
|
78
|
+
<FormRow
|
|
79
|
+
className={classes.buttonFormRow}
|
|
80
|
+
sx={(theme) => ({
|
|
81
|
+
padding: 0,
|
|
82
|
+
[theme.breakpoints.up('sm')]: {
|
|
83
|
+
gridTemplateColumns: 'minmax(200px, 3.5fr) 1fr',
|
|
84
|
+
},
|
|
85
|
+
})}
|
|
86
|
+
>
|
|
87
|
+
<div>{children}</div>
|
|
88
|
+
<Box className={classes.buttonContainer} sx={{ alignSelf: 'center' }}>
|
|
99
89
|
<Button
|
|
100
90
|
fullWidth
|
|
101
91
|
type='submit'
|
|
@@ -105,7 +95,7 @@ export default function SignUpFormInline({
|
|
|
105
95
|
>
|
|
106
96
|
Create Account
|
|
107
97
|
</Button>
|
|
108
|
-
</
|
|
98
|
+
</Box>
|
|
109
99
|
</FormRow>
|
|
110
100
|
</FormRow>
|
|
111
101
|
</Form>
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
} from '@graphcommerce/next-ui'
|
|
9
9
|
import { emailPattern, useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
10
10
|
import { t, Trans } from '@lingui/macro'
|
|
11
|
-
import { TextField } from '@material
|
|
12
|
-
import React from 'react'
|
|
11
|
+
import { TextField } from '@mui/material'
|
|
13
12
|
import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
|
|
14
13
|
import {
|
|
15
14
|
UpdateCustomerEmailDocument,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Controller, useFormAutoSubmit, useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
2
2
|
import { Trans } from '@lingui/macro'
|
|
3
|
-
import { FormControl, FormControlLabel, FormHelperText, Switch } from '@material
|
|
3
|
+
import { FormControl, FormControlLabel, FormHelperText, Switch } from '@mui/material'
|
|
4
4
|
import React, { useEffect, useMemo } from 'react'
|
|
5
5
|
import { AccountAddressFragment } from '../AccountAddress/AccountAddress.gql'
|
|
6
6
|
import { UpdateDefaultAddressDocument } from '../AccountAddresses/UpdateDefaultAddress.gql'
|
|
@@ -24,18 +24,13 @@ export default function UpdateDefaultAddressForm(props: AccountAddressProps) {
|
|
|
24
24
|
|
|
25
25
|
const form = useFormGqlMutation(
|
|
26
26
|
UpdateDefaultAddressDocument,
|
|
27
|
-
{
|
|
28
|
-
mode: 'onChange',
|
|
29
|
-
defaultValues,
|
|
30
|
-
},
|
|
27
|
+
{ mode: 'onChange', defaultValues },
|
|
31
28
|
{ errorPolicy: 'all' },
|
|
32
29
|
)
|
|
33
30
|
|
|
34
31
|
const { handleSubmit, control, error, reset, formState } = form
|
|
35
32
|
|
|
36
|
-
const submit = handleSubmit(() => {
|
|
37
|
-
//
|
|
38
|
-
})
|
|
33
|
+
const submit = handleSubmit(() => {})
|
|
39
34
|
useFormAutoSubmit({ form, submit })
|
|
40
35
|
|
|
41
36
|
useEffect(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApolloError, useApolloClient } from '@
|
|
1
|
+
import { ApolloError, useApolloClient } from '@graphcommerce/graphql'
|
|
2
2
|
import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
|
|
3
3
|
import { t } from '@lingui/macro'
|
|
4
4
|
import { useEffect } from 'react'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useQuery } from '@
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
|
2
2
|
import { useFormAutoSubmit, useFormGqlQuery, useFormPersist } from '@graphcommerce/react-hook-form'
|
|
3
3
|
import { useEffect, useState } from 'react'
|
|
4
4
|
import { CustomerDocument } from './Customer.gql'
|
package/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ApolloCache, NormalizedCacheObject } from '@
|
|
2
|
-
import { setContext } from '@apollo/client/link/context'
|
|
1
|
+
import { ApolloCache, NormalizedCacheObject, setContext } from '@graphcommerce/graphql'
|
|
3
2
|
import { CustomerTokenDocument } from '../hooks/CustomerToken.gql'
|
|
4
3
|
|
|
5
|
-
export const
|
|
4
|
+
export const createCustomerTokenLink = (cache: ApolloCache<NormalizedCacheObject>) =>
|
|
6
5
|
setContext((_, context) => {
|
|
7
6
|
if (!context.headers) context.headers = {}
|
|
8
7
|
try {
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/magento-customer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
6
|
-
"browserslist": [
|
|
7
|
-
"extends @graphcommerce/browserslist-config-pwa"
|
|
8
|
-
],
|
|
9
6
|
"eslintConfig": {
|
|
10
7
|
"extends": "@graphcommerce/eslint-config-pwa",
|
|
11
8
|
"parserOptions": {
|
|
@@ -13,28 +10,23 @@
|
|
|
13
10
|
}
|
|
14
11
|
},
|
|
15
12
|
"devDependencies": {
|
|
16
|
-
"@graphcommerce/
|
|
17
|
-
"@graphcommerce/
|
|
18
|
-
"@graphcommerce/
|
|
19
|
-
"@
|
|
20
|
-
"@playwright/test": "^1.17.1"
|
|
13
|
+
"@graphcommerce/eslint-config-pwa": "^4.0.0",
|
|
14
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.0",
|
|
15
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.0",
|
|
16
|
+
"@playwright/test": "^1.18.1"
|
|
21
17
|
},
|
|
22
18
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@graphcommerce/
|
|
25
|
-
"@graphcommerce/
|
|
26
|
-
"@graphcommerce/magento-
|
|
27
|
-
"@graphcommerce/
|
|
28
|
-
"@graphcommerce/
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"clsx": "^1.1.1",
|
|
34
|
-
"framer-motion": "^5.5.5",
|
|
35
|
-
"next": "^12.0.7",
|
|
19
|
+
"@graphcommerce/graphql": "^3.0.0",
|
|
20
|
+
"@graphcommerce/image": "^3.0.0",
|
|
21
|
+
"@graphcommerce/magento-graphql": "^3.0.0",
|
|
22
|
+
"@graphcommerce/magento-store": "^4.0.0",
|
|
23
|
+
"@graphcommerce/next-ui": "^4.0.0",
|
|
24
|
+
"@graphcommerce/react-hook-form": "^3.0.0",
|
|
25
|
+
"@lingui/macro": "^3.13.2",
|
|
26
|
+
"@mui/material": "^5.4.1",
|
|
27
|
+
"framer-motion": "^6.2.4",
|
|
28
|
+
"next": "^12.0.10",
|
|
36
29
|
"react": "^17.0.2",
|
|
37
30
|
"react-dom": "^17.0.2"
|
|
38
|
-
}
|
|
39
|
-
"gitHead": "41e42c8cd6f565ab0cbba81a1954a0041dc46768"
|
|
31
|
+
}
|
|
40
32
|
}
|
package/typePolicies.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldPolicy } from '@
|
|
1
|
+
import { FieldPolicy } from '@graphcommerce/graphql'
|
|
2
2
|
import { CustomerToken, MigrateCache, Mutation, TypedTypePolicies } from '@graphcommerce/graphql'
|
|
3
3
|
import { CustomerTokenDocument } from './hooks/CustomerToken.gql'
|
|
4
4
|
import { IsEmailAvailableDocument } from './hooks/IsEmailAvailable.gql'
|