@graphcommerce/magento-customer 3.6.44 → 4.1.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +404 -258
  2. package/components/AccountAddress/index.tsx +38 -42
  3. package/components/AccountAddresses/index.tsx +46 -41
  4. package/components/AddressFields/index.tsx +2 -2
  5. package/components/AddressMultiLine/index.tsx +8 -6
  6. package/components/ApolloCustomerError/ApolloCustomerErrorAlert.tsx +2 -2
  7. package/components/ApolloCustomerError/ApolloCustomerErrorFullPage.tsx +3 -5
  8. package/components/ChangeNameForm/index.tsx +1 -2
  9. package/components/ChangePasswordForm/ChangePasswordForm.tsx +2 -4
  10. package/components/CreateCustomerAddressForm/index.tsx +3 -4
  11. package/components/CustomerFab/index.tsx +21 -16
  12. package/components/CustomerMenuFabItem/index.tsx +12 -28
  13. package/components/DeleteCustomerAddressForm/index.tsx +1 -1
  14. package/components/EditAddressForm/index.tsx +6 -17
  15. package/components/ForgotPasswordForm/ForgotPasswordForm.tsx +12 -17
  16. package/components/NameFields/index.tsx +1 -1
  17. package/components/ResetPasswordForm/index.tsx +1 -1
  18. package/components/SignInForm/SignInForm.tsx +7 -21
  19. package/components/SignInForm/SignInFormInline.tsx +35 -29
  20. package/components/SignUpForm/SignUpForm.tsx +1 -2
  21. package/components/SignUpForm/SignUpFormInline.tsx +25 -35
  22. package/components/UpdateCustomerEmailForm/index.tsx +1 -2
  23. package/components/UpdateDefaultAddressForm/index.tsx +3 -8
  24. package/hooks/useExtractCustomerErrors.tsx +1 -1
  25. package/hooks/useFormIsEmailAvailable.tsx +1 -1
  26. package/index.ts +1 -3
  27. package/link/{createAuthLink.ts → createCustomerTokenLink.ts} +2 -3
  28. package/package.json +18 -24
  29. 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 { FormRow, Button, FormActions } from '@graphcommerce/next-ui'
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, makeStyles, TextField } from '@material-ui/core'
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
- const useStyles = makeStyles(
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 className={classes.forgotPass}>
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
- </form>
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 { makeStyles, TextField, Theme } from '@material-ui/core'
4
+ import { Box, SxProps, TextField, Theme } from '@mui/material'
5
5
  import PageLink from 'next/link'
6
- import React, { PropsWithChildren } from 'react'
6
+ import { PropsWithChildren } from 'react'
7
7
  import { SignInDocument, SignInMutationVariables } from './SignIn.gql'
8
8
 
9
- const useStyles = makeStyles(
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
- type InlineSignInFormProps = Omit<SignInMutationVariables, 'password'>
11
+ const { classes } = extendableComponent('SignInFormInline', ['form', 'button'] as const)
29
12
 
30
- export default function SignInFormInline({ email }: PropsWithChildren<InlineSignInFormProps>) {
31
- const classes = useStyles()
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
- <form onSubmit={submitHandler} noValidate className={classes.form}>
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 color='secondary' variant='text' className={classes.button}>
58
- Forgot password?
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
- </form>
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-ui/core'
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 { makeStyles, TextField, Theme } from '@material-ui/core'
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
- helperList?: React.ReactNode
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
- helperList,
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={{ root: classes.form }}>
65
- <FormRow key='inline-signup' classes={{ root: classes.row }}>
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 classes={{ root: classes.buttonFormRow }}>
97
- <div>{helperList}</div>
98
- <div className={classes.buttonContainer}>
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
- </div>
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-ui/core'
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-ui/core'
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 '@apollo/client'
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 '@apollo/client'
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,6 +1,4 @@
1
1
  export * from './components'
2
2
  export * from './hooks'
3
-
4
3
  export * from './typePolicies'
5
-
6
- export * from './link/createAuthLink'
4
+ export * from './link/createCustomerTokenLink'
@@ -1,8 +1,7 @@
1
- import { ApolloCache, NormalizedCacheObject } from '@apollo/client'
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 createAuthLink = (cache: ApolloCache<NormalizedCacheObject>) =>
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,10 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-customer",
3
- "version": "3.6.44",
3
+ "homepage": "https://www.graphcommerce.org/",
4
+ "repository": "github:graphcommerce-org/graphcommerce",
5
+ "version": "4.1.0",
4
6
  "sideEffects": false,
5
7
  "prettier": "@graphcommerce/prettier-config-pwa",
6
- "browserslist": [
7
- "extends @graphcommerce/browserslist-config-pwa"
8
- ],
9
8
  "eslintConfig": {
10
9
  "extends": "@graphcommerce/eslint-config-pwa",
11
10
  "parserOptions": {
@@ -13,28 +12,23 @@
13
12
  }
14
13
  },
15
14
  "devDependencies": {
16
- "@graphcommerce/browserslist-config-pwa": "^3.0.3",
17
- "@graphcommerce/eslint-config-pwa": "^3.1.10",
18
- "@graphcommerce/prettier-config-pwa": "^3.0.5",
19
- "@graphcommerce/typescript-config-pwa": "^3.1.2",
20
- "@playwright/test": "^1.17.1"
15
+ "@graphcommerce/eslint-config-pwa": "^4.0.1",
16
+ "@graphcommerce/prettier-config-pwa": "^4.0.1",
17
+ "@graphcommerce/typescript-config-pwa": "^4.0.1",
18
+ "@playwright/test": "^1.18.1"
21
19
  },
22
20
  "dependencies": {
23
- "@apollo/client": "^3.5.6",
24
- "@graphcommerce/graphql": "^2.105.13",
25
- "@graphcommerce/image": "^2.105.13",
26
- "@graphcommerce/magento-graphql": "^2.104.13",
27
- "@graphcommerce/magento-store": "^3.4.12",
28
- "@graphcommerce/next-ui": "^3.25.3",
29
- "@graphcommerce/react-hook-form": "^2.104.7",
30
- "@lingui/macro": "^3.13.0",
31
- "@material-ui/core": "^4.12.3",
32
- "@material-ui/lab": "^4.0.0-alpha.60",
33
- "clsx": "^1.1.1",
34
- "framer-motion": "^5.5.5",
35
- "next": "^12.0.7",
21
+ "@graphcommerce/graphql": "^3.0.1",
22
+ "@graphcommerce/image": "^3.0.1",
23
+ "@graphcommerce/magento-graphql": "^3.0.1",
24
+ "@graphcommerce/magento-store": "^4.0.1",
25
+ "@graphcommerce/next-ui": "^4.1.0",
26
+ "@graphcommerce/react-hook-form": "^3.0.1",
27
+ "@lingui/macro": "^3.13.2",
28
+ "@mui/material": "^5.4.1",
29
+ "framer-motion": "^6.2.4",
30
+ "next": "^12.0.10",
36
31
  "react": "^17.0.2",
37
32
  "react-dom": "^17.0.2"
38
- },
39
- "gitHead": "41e42c8cd6f565ab0cbba81a1954a0041dc46768"
33
+ }
40
34
  }
package/typePolicies.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FieldPolicy } from '@apollo/client'
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'