@graphcommerce/magento-customer 8.0.6-canary.3 → 8.0.6

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 CHANGED
@@ -1,20 +1,6 @@
1
1
  # Change Log
2
2
 
3
- ## 8.0.6-canary.3
4
-
5
- ## 8.0.6-canary.2
6
-
7
- ### Patch Changes
8
-
9
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
10
- ([@FrankHarland](https://github.com/FrankHarland))
11
-
12
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of useFormPersist to the <FormPersist/> component to prevent rerenders.
13
- ([@FrankHarland](https://github.com/FrankHarland))
14
-
15
- ## 8.0.6-canary.1
16
-
17
- ## 8.0.6-canary.0
3
+ ## 8.0.6
18
4
 
19
5
  ## 8.0.5
20
6
 
@@ -1,4 +1,5 @@
1
1
  import { TextFieldElement, FieldValues, FieldPath } from '@graphcommerce/ecommerce-ui'
2
+ import { InputCheckmark } from '@graphcommerce/next-ui'
2
3
  import { Trans } from '@lingui/react'
3
4
  import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
4
5
 
@@ -7,7 +8,7 @@ export function AddressAddition<
7
8
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
8
9
  >(props: AddressFieldsOptions<TFieldValues, TName>) {
9
10
  const form = useAddressFieldsForm<TFieldValues, TName>(props)
10
- const { control, name, readOnly, required } = form
11
+ const { control, name, readOnly, required, valid } = form
11
12
 
12
13
  return (
13
14
  <TextFieldElement
@@ -18,8 +19,10 @@ export function AddressAddition<
18
19
  required={required[name.addition]}
19
20
  label={<Trans id='Addition' />}
20
21
  autoComplete='address-line3'
21
- showValid
22
- InputProps={{ readOnly }}
22
+ InputProps={{
23
+ readOnly,
24
+ endAdornment: <InputCheckmark show={valid[name.addition]} />,
25
+ }}
23
26
  />
24
27
  )
25
28
  }
@@ -1,4 +1,5 @@
1
1
  import { TextFieldElement, FieldValues, FieldPath } from '@graphcommerce/ecommerce-ui'
2
+ import { InputCheckmark } from '@graphcommerce/next-ui'
2
3
  import { Trans } from '@lingui/react'
3
4
  import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
4
5
 
@@ -7,7 +8,7 @@ export function AddressCity<
7
8
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
8
9
  >(props: AddressFieldsOptions<TFieldValues, TName>) {
9
10
  const form = useAddressFieldsForm<TFieldValues, TName>(props)
10
- const { control, name, readOnly, required } = form
11
+ const { control, name, readOnly, required, valid } = form
11
12
 
12
13
  return (
13
14
  <TextFieldElement
@@ -17,8 +18,10 @@ export function AddressCity<
17
18
  type='text'
18
19
  required={required[name.city]}
19
20
  label={<Trans id='City' />}
20
- showValid
21
- InputProps={{ readOnly }}
21
+ InputProps={{
22
+ readOnly,
23
+ endAdornment: <InputCheckmark show={valid[name.city]} />,
24
+ }}
22
25
  />
23
26
  )
24
27
  }
@@ -1,7 +1,7 @@
1
1
  import { SelectElement, FieldValues, FieldPath, useWatch } from '@graphcommerce/ecommerce-ui'
2
2
  import { useQuery } from '@graphcommerce/graphql'
3
3
  import { CountryRegionsDocument } from '@graphcommerce/magento-store'
4
- import { FormRow, filterNonNullableKeys } from '@graphcommerce/next-ui'
4
+ import { FormRow, InputCheckmark, filterNonNullableKeys } from '@graphcommerce/next-ui'
5
5
  import { Trans } from '@lingui/react'
6
6
  import { useMemo } from 'react'
7
7
  import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
@@ -43,7 +43,7 @@ export function AddressCountryRegion<
43
43
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
44
44
  >(props: AddressFieldsOptions<TFieldValues, TName>) {
45
45
  const form = useAddressCountryRegion<TFieldValues, TName>(props)
46
- const { control, name, readOnly, required, countryList, regionList } = form
46
+ const { control, name, readOnly, required, valid, countryList, regionList } = form
47
47
 
48
48
  return (
49
49
  <FormRow>
@@ -54,8 +54,10 @@ export function AddressCountryRegion<
54
54
  variant='outlined'
55
55
  label={<Trans id='Country' />}
56
56
  required={required[name.countryCode]}
57
- showValid
58
- InputProps={{ readOnly }}
57
+ InputProps={{
58
+ readOnly,
59
+ endAdornment: <InputCheckmark show={valid[name.countryCode]} select />,
60
+ }}
59
61
  options={countryList.map((country) => ({
60
62
  id: country.two_letter_abbreviation,
61
63
  label: country.full_name_locale,
@@ -70,8 +72,10 @@ export function AddressCountryRegion<
70
72
  variant='outlined'
71
73
  label={<Trans id='Region' />}
72
74
  required
73
- showValid
74
- InputProps={{ readOnly }}
75
+ InputProps={{
76
+ readOnly,
77
+ endAdornment: <InputCheckmark show={valid[name.regionId]} select />,
78
+ }}
75
79
  options={regionList.map((region) => ({ ...region, label: region.name }))}
76
80
  />
77
81
  )}
@@ -4,6 +4,7 @@ import {
4
4
  FieldPath,
5
5
  houseNumberPattern,
6
6
  } from '@graphcommerce/ecommerce-ui'
7
+ import { InputCheckmark } from '@graphcommerce/next-ui'
7
8
  import { i18n } from '@lingui/core'
8
9
  import { Trans } from '@lingui/react'
9
10
  import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
@@ -13,7 +14,7 @@ export function AddressHousenumber<
13
14
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
14
15
  >(props: AddressFieldsOptions<TFieldValues, TName>) {
15
16
  const form = useAddressFieldsForm<TFieldValues, TName>(props)
16
- const { control, name, readOnly, required } = form
17
+ const { control, name, readOnly, required, valid } = form
17
18
  return (
18
19
  <TextFieldElement
19
20
  control={control}
@@ -29,8 +30,10 @@ export function AddressHousenumber<
29
30
  type='text'
30
31
  label={<Trans id='Housenumber' />}
31
32
  autoComplete='address-line2'
32
- showValid
33
- InputProps={{ readOnly }}
33
+ InputProps={{
34
+ readOnly,
35
+ endAdornment: <InputCheckmark show={valid[name.houseNumber]} />,
36
+ }}
34
37
  />
35
38
  )
36
39
  }
@@ -1,4 +1,5 @@
1
1
  import { FieldPath, FieldValues, TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
+ import { InputCheckmark } from '@graphcommerce/next-ui'
2
3
  import { Trans } from '@lingui/react'
3
4
  import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
4
5
 
@@ -7,7 +8,7 @@ export function AddressPostcode<
7
8
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
8
9
  >(props: AddressFieldsOptions<TFieldValues, TName>) {
9
10
  const form = useAddressFieldsForm<TFieldValues, TName>(props)
10
- const { control, name, required } = form
11
+ const { control, name, readOnly, required, valid } = form
11
12
 
12
13
  return (
13
14
  <TextFieldElement
@@ -17,7 +18,10 @@ export function AddressPostcode<
17
18
  type='text'
18
19
  required={required[name.postcode]}
19
20
  label={<Trans id='Postcode' />}
20
- showValid
21
+ InputProps={{
22
+ readOnly,
23
+ endAdornment: <InputCheckmark show={valid[name.postcode]} />,
24
+ }}
21
25
  />
22
26
  )
23
27
  }
@@ -1,4 +1,5 @@
1
1
  import { TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
+ import { InputCheckmark } from '@graphcommerce/next-ui'
2
3
  import { FieldValues, FieldPath } from '@graphcommerce/react-hook-form'
3
4
  import { Trans } from '@lingui/react'
4
5
  import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
@@ -8,7 +9,7 @@ export function AddressStreet<
8
9
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
9
10
  >(props: AddressFieldsOptions<TFieldValues, TName>) {
10
11
  const form = useAddressFieldsForm<TFieldValues, TName>(props)
11
- const { control, name, readOnly, required } = form
12
+ const { control, name, readOnly, required, valid } = form
12
13
  return (
13
14
  <TextFieldElement
14
15
  variant='outlined'
@@ -18,8 +19,10 @@ export function AddressStreet<
18
19
  type='text'
19
20
  label={<Trans id='Street' />}
20
21
  autoComplete='address-line1'
21
- showValid
22
- InputProps={{ readOnly }}
22
+ InputProps={{
23
+ readOnly,
24
+ endAdornment: <InputCheckmark show={valid[name.street]} />,
25
+ }}
23
26
  />
24
27
  )
25
28
  }
@@ -1,4 +1,4 @@
1
- import { ApolloErrorSnackbar, TextFieldElement } from '@graphcommerce/ecommerce-ui'
1
+ import { ApolloErrorSnackbar } from '@graphcommerce/ecommerce-ui'
2
2
  import { useQuery } from '@graphcommerce/graphql'
3
3
  import { CountryCodeEnum } from '@graphcommerce/graphql-mesh'
4
4
  import { CountryRegionsDocument, StoreConfigDocument } from '@graphcommerce/magento-store'
@@ -57,7 +57,7 @@ export function CreateCustomerAddressForm() {
57
57
  { errorPolicy: 'all' },
58
58
  )
59
59
 
60
- const { handleSubmit, formState, required, error, control, valid, data } = form
60
+ const { handleSubmit, formState, required, error, muiRegister, valid, data } = form
61
61
  const submitHandler = handleSubmit((_, e) => {
62
62
  if (!formState.errors) e?.target.reset()
63
63
  })
@@ -69,21 +69,19 @@ export function CreateCustomerAddressForm() {
69
69
  <AddressFields form={form} name={{ regionId: 'region.region_id' }} />
70
70
 
71
71
  <FormRow>
72
- <TextFieldElement
72
+ <TextField
73
73
  variant='outlined'
74
74
  type='text'
75
75
  error={!!formState.errors.telephone}
76
76
  required={required.telephone}
77
77
  label={<Trans id='Telephone' />}
78
- control={control}
79
- name='telephone'
80
- rules={{
78
+ {...muiRegister('telephone', {
81
79
  required: required.telephone,
82
80
  pattern: { value: phonePattern, message: i18n._(/* i18n */ 'Invalid phone number') },
83
- }}
81
+ })}
84
82
  helperText={formState.isSubmitted && formState.errors.telephone?.message}
85
83
  disabled={formState.isSubmitting}
86
- showValid
84
+ InputProps={{ endAdornment: <InputCheckmark show={valid.telephone} /> }}
87
85
  />
88
86
  </FormRow>
89
87
 
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
- import { ApolloErrorSnackbar, TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
+ import { ApolloErrorSnackbar } from '@graphcommerce/ecommerce-ui'
3
3
  import { useQuery } from '@graphcommerce/graphql'
4
4
  import { CountryRegionsDocument } from '@graphcommerce/magento-store'
5
5
  import {
@@ -23,9 +23,6 @@ import { UpdateCustomerAddressDocument } from './UpdateCustomerAddress.gql'
23
23
  type EditAddressFormProps = {
24
24
  address?: AccountAddressFragment
25
25
  sx?: SxProps<Theme>
26
- /**
27
- * @deprecated not used, can be safely removed.
28
- */
29
26
  onCompleteRoute?: string
30
27
  }
31
28
 
@@ -78,7 +75,7 @@ export function EditAddressForm(props: EditAddressFormProps) {
78
75
  { errorPolicy: 'all' },
79
76
  )
80
77
 
81
- const { handleSubmit, formState, required, error, control, valid } = form
78
+ const { handleSubmit, formState, required, error, muiRegister, valid } = form
82
79
  const submitHandler = handleSubmit(() => {})
83
80
 
84
81
  return (
@@ -88,21 +85,19 @@ export function EditAddressForm(props: EditAddressFormProps) {
88
85
  <AddressFields form={form} name={{ regionId: 'region.region_id' }} />
89
86
 
90
87
  <FormRow>
91
- <TextFieldElement
92
- control={control}
93
- name='telephone'
88
+ <TextField
94
89
  variant='outlined'
95
90
  type='text'
96
91
  error={!!formState.errors.telephone}
97
92
  required={required.telephone}
98
93
  label={<Trans id='Telephone' />}
99
- rules={{
94
+ {...muiRegister('telephone', {
100
95
  required: required.telephone,
101
96
  pattern: { value: phonePattern, message: i18n._(/* i18n */ 'Invalid phone number') },
102
- }}
97
+ })}
103
98
  helperText={formState.isSubmitted && formState.errors.telephone?.message}
104
99
  disabled={formState.isSubmitting}
105
- showValid
100
+ InputProps={{ endAdornment: <InputCheckmark show={valid.telephone} /> }}
106
101
  />
107
102
  </FormRow>
108
103
 
@@ -1,10 +1,9 @@
1
- import { TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
1
  import { Button, Form, FormActions, FormRow } from '@graphcommerce/next-ui'
3
2
  import { emailPattern, useFormGqlMutation } from '@graphcommerce/react-hook-form'
4
3
  import { i18n } from '@lingui/core'
5
4
  import { Trans } from '@lingui/react'
6
5
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
- import { Alert, SxProps, Theme } from '@mui/material'
6
+ import { TextField, Alert, SxProps, Theme } from '@mui/material'
8
7
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
9
8
  import {
10
9
  ForgotPasswordDocument,
@@ -17,7 +16,7 @@ export function ForgotPasswordForm(props: { sx?: SxProps<Theme> }) {
17
16
  const form = useFormGqlMutation<ForgotPasswordMutation, ForgotPasswordMutationVariables>(
18
17
  ForgotPasswordDocument,
19
18
  )
20
- const { control, handleSubmit, required, data, formState, error } = form
19
+ const { muiRegister, handleSubmit, required, data, formState, error } = form
21
20
  const submitHandler = handleSubmit(() => {})
22
21
 
23
22
  if (formState.isSubmitSuccessful && data) {
@@ -38,20 +37,18 @@ export function ForgotPasswordForm(props: { sx?: SxProps<Theme> }) {
38
37
  return (
39
38
  <Form onSubmit={submitHandler} noValidate sx={sx}>
40
39
  <FormRow>
41
- <TextFieldElement
40
+ <TextField
42
41
  variant='outlined'
43
42
  type='text'
44
43
  error={!!formState.errors.email}
45
44
  label={<Trans id='Email' />}
46
45
  required={required.email}
47
- name='email'
48
- control={control}
49
- rules={{
46
+ {...muiRegister('email', {
47
+ required: required.email,
50
48
  pattern: { value: emailPattern, message: i18n._(/* i18n */ 'Invalid email address') },
51
- }}
49
+ })}
52
50
  helperText={formState.errors.email?.message}
53
51
  disabled={formState.isSubmitting}
54
- showValid
55
52
  />
56
53
  </FormRow>
57
54
 
@@ -1,5 +1,5 @@
1
1
  import { SelectElement, TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
- import { FormRow } from '@graphcommerce/next-ui'
2
+ import { FormRow, InputCheckmark } from '@graphcommerce/next-ui'
3
3
  import { assertFormGqlOperation, UseFormReturn } from '@graphcommerce/react-hook-form'
4
4
  import { i18n } from '@lingui/core'
5
5
  import { Trans } from '@lingui/react'
@@ -27,7 +27,7 @@ export function NameFields(props: NameFieldProps) {
27
27
  const { prefix, form, readOnly, prefixes = [mr, mrs, other] } = props
28
28
  assertFormGqlOperation<NameFieldValues>(form)
29
29
 
30
- const { control, required } = form
30
+ const { control, required, valid } = form
31
31
 
32
32
  return (
33
33
  <>
@@ -40,32 +40,41 @@ export function NameFields(props: NameFieldProps) {
40
40
  required={required.prefix}
41
41
  name='prefix'
42
42
  label={<Trans id='Prefix' />}
43
- showValid
44
- InputProps={{ readOnly }}
45
- options={prefixes.map((option) => ({ id: option, label: option }))}
43
+ InputProps={{
44
+ readOnly,
45
+ endAdornment: <InputCheckmark show={valid.prefix} select />,
46
+ }}
47
+ options={prefixes.map((option) => ({
48
+ id: option,
49
+ label: option,
50
+ }))}
46
51
  />
47
52
  </FormRow>
48
53
  )}
49
54
  <FormRow>
50
55
  <TextFieldElement
51
- control={control}
56
+ control={form.control}
52
57
  name='firstname'
53
58
  required={required.firstname}
54
59
  variant='outlined'
55
60
  type='text'
56
61
  label={<Trans id='First Name' />}
57
- InputProps={{ readOnly }}
58
- showValid
62
+ InputProps={{
63
+ readOnly,
64
+ endAdornment: <InputCheckmark show={valid.firstname} />,
65
+ }}
59
66
  />
60
67
  <TextFieldElement
61
- control={control}
68
+ control={form.control}
62
69
  name='lastname'
63
70
  required={required.lastname}
64
71
  variant='outlined'
65
72
  type='text'
66
73
  label={<Trans id='Last Name' />}
67
- InputProps={{ readOnly }}
68
- showValid
74
+ InputProps={{
75
+ readOnly,
76
+ endAdornment: <InputCheckmark show={valid.lastname} />,
77
+ }}
69
78
  />
70
79
  </FormRow>
71
80
  </>
@@ -1,9 +1,10 @@
1
- import { PasswordRepeatElement, SwitchElement } from '@graphcommerce/ecommerce-ui'
1
+ import { PasswordRepeatElement } from '@graphcommerce/ecommerce-ui'
2
2
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
3
3
  import { Button, FormActions, FormRow } from '@graphcommerce/next-ui'
4
- import { FormPersist, useFormGqlMutation } from '@graphcommerce/react-hook-form'
4
+ import { useFormGqlMutation, useFormPersist } from '@graphcommerce/react-hook-form'
5
5
  import { Trans } from '@lingui/react'
6
- import { Alert } from '@mui/material'
6
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
+ import { Alert, FormControlLabel, Switch } from '@mui/material'
7
8
  import { useSignInForm } from '../../hooks/useSignInForm'
8
9
  import { ApolloCustomerErrorSnackbar } from '../ApolloCustomerError/ApolloCustomerErrorSnackbar'
9
10
  import { NameFields } from '../NameFields/NameFields'
@@ -38,11 +39,13 @@ export function SignUpForm(props: SignUpFormProps) {
38
39
  { errorPolicy: 'all' },
39
40
  )
40
41
 
41
- const { handleSubmit, required, formState, error, control } = form
42
+ const { muiRegister, handleSubmit, required, formState, error, control } = form
42
43
  const [remainingError, inputError] = graphqlErrorByCategory({ category: 'graphql-input', error })
43
44
 
44
45
  const submitHandler = handleSubmit(() => {})
45
46
 
47
+ useFormPersist({ form, name: 'SignUp', exclude: ['password', 'confirmPassword'] })
48
+
46
49
  if (requireEmailValidation && form.formState.isSubmitSuccessful) {
47
50
  return (
48
51
  <Alert>
@@ -54,7 +57,6 @@ export function SignUpForm(props: SignUpFormProps) {
54
57
  return (
55
58
  <form onSubmit={submitHandler} noValidate>
56
59
  <FormRow>
57
- <FormPersist form={form} name='SignUp' exclude={['password', 'confirmPassword']} />
58
60
  <ValidatedPasswordElement
59
61
  control={control}
60
62
  name='password'
@@ -82,9 +84,9 @@ export function SignUpForm(props: SignUpFormProps) {
82
84
 
83
85
  <NameFields form={form} prefix />
84
86
 
85
- <SwitchElement
86
- control={control}
87
- name='isSubscribed'
87
+ <FormControlLabel
88
+ control={<Switch color='primary' />}
89
+ {...muiRegister('isSubscribed', { required: required.isSubscribed })}
88
90
  disabled={formState.isSubmitting}
89
91
  label={<Trans id='Subscribe to newsletter' />}
90
92
  />
@@ -1,4 +1,4 @@
1
- import { PasswordElement, TextFieldElement } from '@graphcommerce/ecommerce-ui'
1
+ import { PasswordElement } from '@graphcommerce/ecommerce-ui'
2
2
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
3
3
  import {
4
4
  Button,
@@ -12,6 +12,7 @@ import { emailPattern, useFormGqlMutation } from '@graphcommerce/react-hook-form
12
12
  import { i18n } from '@lingui/core'
13
13
  import { Trans } from '@lingui/react'
14
14
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
15
+ import { TextField } from '@mui/material'
15
16
  import { ApolloCustomerErrorSnackbar } from '../ApolloCustomerError'
16
17
  import {
17
18
  UpdateCustomerEmailDocument,
@@ -31,17 +32,13 @@ export function UpdateCustomerEmailForm(props: UpdateCustomerEmailFormProps) {
31
32
  UpdateCustomerEmailMutationVariables & { currentEmail?: string; confirmEmail?: string }
32
33
  >(
33
34
  UpdateCustomerEmailDocument,
34
- {
35
- defaultValues: {
36
- currentEmail: email,
37
- },
38
- },
35
+ {},
39
36
  {
40
37
  errorPolicy: 'all',
41
38
  },
42
39
  )
43
40
 
44
- const { handleSubmit, error, required, formState, watch, reset, control } = form
41
+ const { handleSubmit, error, required, formState, watch, muiRegister, reset, control } = form
45
42
  const [remainingError, authenticationError] = graphqlErrorByCategory({
46
43
  category: 'graphql-authentication',
47
44
  error,
@@ -54,20 +51,30 @@ export function UpdateCustomerEmailForm(props: UpdateCustomerEmailFormProps) {
54
51
  return (
55
52
  <Form onSubmit={submit} noValidate>
56
53
  <FormRow>
57
- <TextFieldElement
54
+ <TextField
55
+ key='current-email'
58
56
  variant='outlined'
59
57
  type='text'
58
+ autoComplete='email'
59
+ autoFocus
60
+ error={formState.isSubmitted && !!formState.errors.currentEmail}
61
+ helperText={formState.isSubmitted && formState.errors.currentEmail?.message}
60
62
  label={<Trans id='Current email' />}
61
63
  required
62
- name='currentEmail'
63
- control={control}
64
- showValid
65
- InputProps={{ readOnly: true }}
64
+ value={email}
65
+ {...muiRegister('currentEmail', {
66
+ required: true,
67
+ pattern: { value: emailPattern, message: '' },
68
+ })}
69
+ InputProps={{
70
+ readOnly: true,
71
+ }}
66
72
  />
67
73
  </FormRow>
68
74
 
69
75
  <FormRow>
70
- <TextFieldElement
76
+ <TextField
77
+ key='email'
71
78
  variant='outlined'
72
79
  type='text'
73
80
  autoComplete='off'
@@ -75,15 +82,12 @@ export function UpdateCustomerEmailForm(props: UpdateCustomerEmailFormProps) {
75
82
  helperText={formState.isSubmitted && formState.errors.email?.message}
76
83
  label={<Trans id='New email' />}
77
84
  required={required.email}
78
- name='email'
79
- rules={{
85
+ {...muiRegister('email', {
80
86
  required: true,
81
87
  pattern: { value: emailPattern, message: '' },
82
- }}
83
- showValid
84
- control={control}
88
+ })}
85
89
  />
86
- <TextFieldElement
90
+ <TextField
87
91
  key='confirm-email'
88
92
  variant='outlined'
89
93
  type='text'
@@ -92,13 +96,10 @@ export function UpdateCustomerEmailForm(props: UpdateCustomerEmailFormProps) {
92
96
  helperText={formState.isSubmitted && formState.errors.confirmEmail?.message}
93
97
  label={<Trans id='Confirm new email' />}
94
98
  required
95
- name='confirmEmail'
96
- rules={{
99
+ {...muiRegister('confirmEmail', {
97
100
  required: true,
98
101
  validate: (value) => value === watchNewEmail || i18n._(/* i18n */ "Emails don't match"),
99
- }}
100
- showValid
101
- control={control}
102
+ })}
102
103
  />
103
104
  </FormRow>
104
105
 
@@ -1,4 +1,4 @@
1
- import { Controller, FormAutoSubmit, useFormGqlMutation } from '@graphcommerce/react-hook-form'
1
+ import { Controller, useFormAutoSubmit, useFormGqlMutation } from '@graphcommerce/react-hook-form'
2
2
  import { Trans } from '@lingui/react'
3
3
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
4
4
  import { FormControl, FormControlLabel, FormHelperText, Switch } from '@mui/material'
@@ -32,6 +32,7 @@ export function UpdateDefaultAddressForm(props: UpdateDefaultAddressFormProps) {
32
32
  const { handleSubmit, control, error, reset, formState } = form
33
33
 
34
34
  const submit = handleSubmit(() => {})
35
+ useFormAutoSubmit({ form, submit })
35
36
 
36
37
  useEffect(() => {
37
38
  reset(defaultValues)
@@ -39,7 +40,6 @@ export function UpdateDefaultAddressForm(props: UpdateDefaultAddressFormProps) {
39
40
 
40
41
  return (
41
42
  <form onSubmit={() => {}} noValidate>
42
- <FormAutoSubmit control={control} submit={submit} />
43
43
  <Controller
44
44
  name='defaultShipping'
45
45
  control={control}
@@ -1,7 +1,7 @@
1
1
  import { usePageContext } from '@graphcommerce/framer-next-pages'
2
2
  import { useQuery } from '@graphcommerce/graphql'
3
- import { useUrlQuery } from '@graphcommerce/next-ui'
4
3
  import { useFormGqlQuery } from '@graphcommerce/react-hook-form'
4
+ import { useRouter } from 'next/router'
5
5
  import { useEffect } from 'react'
6
6
  import { CustomerDocument } from './Customer.gql'
7
7
  import {
@@ -10,6 +10,7 @@ import {
10
10
  IsEmailAvailableQueryVariables,
11
11
  } from './IsEmailAvailable.gql'
12
12
  import { useCustomerSession } from './useCustomerSession'
13
+ import { useUrlQuery } from '@graphcommerce/next-ui'
13
14
 
14
15
  export type UseFormIsEmailAvailableProps = {
15
16
  onSubmitted?: (data: { email: string }) => void
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": "8.0.6-canary.3",
5
+ "version": "8.0.6",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,19 +12,19 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^8.0.6-canary.3",
16
- "@graphcommerce/eslint-config-pwa": "^8.0.6-canary.3",
17
- "@graphcommerce/framer-next-pages": "^8.0.6-canary.3",
18
- "@graphcommerce/framer-utils": "^8.0.6-canary.3",
19
- "@graphcommerce/graphql": "^8.0.6-canary.3",
20
- "@graphcommerce/graphql-mesh": "^8.0.6-canary.3",
21
- "@graphcommerce/image": "^8.0.6-canary.3",
22
- "@graphcommerce/magento-graphql": "^8.0.6-canary.3",
23
- "@graphcommerce/magento-store": "^8.0.6-canary.3",
24
- "@graphcommerce/next-ui": "^8.0.6-canary.3",
25
- "@graphcommerce/prettier-config-pwa": "^8.0.6-canary.3",
26
- "@graphcommerce/react-hook-form": "^8.0.6-canary.3",
27
- "@graphcommerce/typescript-config-pwa": "^8.0.6-canary.3",
15
+ "@graphcommerce/ecommerce-ui": "^8.0.6",
16
+ "@graphcommerce/eslint-config-pwa": "^8.0.6",
17
+ "@graphcommerce/framer-next-pages": "^8.0.6",
18
+ "@graphcommerce/framer-utils": "^8.0.6",
19
+ "@graphcommerce/graphql": "^8.0.6",
20
+ "@graphcommerce/graphql-mesh": "^8.0.6",
21
+ "@graphcommerce/image": "^8.0.6",
22
+ "@graphcommerce/magento-graphql": "^8.0.6",
23
+ "@graphcommerce/magento-store": "^8.0.6",
24
+ "@graphcommerce/next-ui": "^8.0.6",
25
+ "@graphcommerce/prettier-config-pwa": "^8.0.6",
26
+ "@graphcommerce/react-hook-form": "^8.0.6",
27
+ "@graphcommerce/typescript-config-pwa": "^8.0.6",
28
28
  "@lingui/core": "^4.2.1",
29
29
  "@lingui/macro": "^4.2.1",
30
30
  "@lingui/react": "^4.2.1",