@graphcommerce/magento-cart-email 3.0.21 → 3.0.24

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,5 +1,39 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.0.24
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`c63ab89c2`](https://github.com/graphcommerce-org/graphcommerce/commit/c63ab89c20cb81d79188900d57f3d65a7bba71cc), [`238aa4d34`](https://github.com/graphcommerce-org/graphcommerce/commit/238aa4d3478773b8cb0973f4112c9829e59e16d6), [`afc67103d`](https://github.com/graphcommerce-org/graphcommerce/commit/afc67103d0e00583e274465036fd287537f95e79)]:
8
+ - @graphcommerce/magento-product@4.4.2
9
+ - @graphcommerce/magento-customer@4.4.1
10
+ - @graphcommerce/next-ui@4.8.3
11
+ - @graphcommerce/magento-cart@4.3.3
12
+ - @graphcommerce/magento-store@4.2.7
13
+
14
+ ## 3.0.23
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [[`d6262de71`](https://github.com/graphcommerce-org/graphcommerce/commit/d6262de71d2254a2b0b492e1a60f9e141767470e), [`c8c246b8a`](https://github.com/graphcommerce-org/graphcommerce/commit/c8c246b8aaab0621b68a2fca2a1c529a56fad962), [`e3005fe63`](https://github.com/graphcommerce-org/graphcommerce/commit/e3005fe6306093d47b08c6756c21c8175649e30b)]:
19
+ - @graphcommerce/magento-customer@4.4.0
20
+ - @graphcommerce/magento-cart@4.3.2
21
+ - @graphcommerce/next-ui@4.8.2
22
+ - @graphcommerce/magento-product@4.4.1
23
+ - @graphcommerce/magento-store@4.2.6
24
+
25
+ ## 3.0.22
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [[`a9df81310`](https://github.com/graphcommerce-org/graphcommerce/commit/a9df81310c051876dd82fb2819105dece47cc213), [`b359fe252`](https://github.com/graphcommerce-org/graphcommerce/commit/b359fe252a50bb8195601ba97c3eef6a7be146ba), [`f167f9963`](https://github.com/graphcommerce-org/graphcommerce/commit/f167f99630966a7de43717937d43669e66132494)]:
30
+ - @graphcommerce/next-ui@4.8.1
31
+ - @graphcommerce/magento-product@4.4.0
32
+ - @graphcommerce/magento-cart@4.3.1
33
+ - @graphcommerce/magento-customer@4.3.2
34
+ - @graphcommerce/magento-store@4.2.5
35
+ - @graphcommerce/image@3.1.6
36
+
3
37
  ## 3.0.21
4
38
 
5
39
  ### Patch Changes
@@ -14,6 +14,7 @@ import { emailPattern, useFormCompose, UseFormComposeOptions } from '@graphcomme
14
14
  import { Trans } from '@lingui/react'
15
15
  import { CircularProgress, TextField, Typography, Alert, Button } from '@mui/material'
16
16
  import { AnimatePresence } from 'framer-motion'
17
+ import PageLink from 'next/link'
17
18
  import React, { useEffect, useState } from 'react'
18
19
  import { CartEmailDocument } from './CartEmail.gql'
19
20
  import { SetGuestEmailOnCartDocument } from './SetGuestEmailOnCart.gql'
@@ -28,12 +29,10 @@ const { classes } = extendableComponent(name, parts)
28
29
 
29
30
  export function EmailForm(props: EmailFormProps) {
30
31
  const { step, children } = props
31
- const [expand, setExpand] = useState(false)
32
-
33
- useMergeCustomerCart()
34
32
 
35
33
  const [setGuestEmailOnCart] = useMutation(SetGuestEmailOnCartDocument)
36
34
  const { data: cartData } = useCartQuery(CartEmailDocument)
35
+
37
36
  const { mode, form, submit } = useFormIsEmailAvailable({ email: cartData?.cart?.email })
38
37
 
39
38
  const { formState, muiRegister, required, watch, error, getValues } = form
@@ -57,80 +56,42 @@ export function EmailForm(props: EmailFormProps) {
57
56
 
58
57
  if (mode === 'signin') {
59
58
  endAdornment = (
60
- <Button color='secondary' style={{ whiteSpace: 'nowrap' }} onClick={() => setExpand(!expand)}>
61
- {expand ? <Trans id='Close' /> : <Trans id='Sign in' />}
62
- </Button>
63
- )
64
- }
65
- if (mode === 'signup') {
66
- endAdornment = (
67
- <Button color='secondary' style={{ whiteSpace: 'nowrap' }} onClick={() => setExpand(!expand)}>
68
- {expand ? <Trans id='Close' /> : <Trans id='Create Account' />}
69
- </Button>
59
+ <PageLink href='/account/signin' passHref>
60
+ <Button color='secondary' style={{ whiteSpace: 'nowrap' }}>
61
+ <Trans id='Sign in' />
62
+ </Button>
63
+ </PageLink>
70
64
  )
71
65
  }
72
66
  if (formState.isSubmitting) endAdornment = <CircularProgress />
73
67
 
74
68
  return (
75
- <FormDiv>
76
- <AnimatePresence initial={false}>
77
- <AnimatedRow key='emailform'>
78
- <form noValidate onSubmit={submit}>
79
- <FormRow>
80
- <Typography variant='h5' component='h2' gutterBottom>
81
- <Trans id='Personal details' />
82
- </Typography>
83
- </FormRow>
84
- <FormRow className={classes.formRow} sx={{ py: 0 }}>
85
- <TextField
86
- variant='outlined'
87
- type='email'
88
- error={formState.isSubmitted && !!formState.errors.email}
89
- helperText={formState.isSubmitted && formState.errors.email?.message}
90
- label={<Trans id='Email' />}
91
- required={required.email}
92
- {...muiRegister('email', {
93
- required: required.email,
94
- pattern: { value: emailPattern, message: '' },
95
- })}
96
- InputProps={{
97
- autoComplete: 'email',
98
- endAdornment,
99
- readOnly: mode === 'signedin' || mode === 'session-expired',
100
- }}
101
- />
102
- </FormRow>
103
- <ApolloCartErrorAlert error={error} />
104
- </form>
105
- </AnimatedRow>
106
-
107
- {((mode === 'signin' && expand) || mode === 'session-expired') && (
108
- <AnimatedRow key='signin-form-inline'>
109
- <FormRow>
110
- <SignInFormInline email={watch('email')} />
111
- </FormRow>
112
- </AnimatedRow>
113
- )}
114
-
115
- {mode === 'signup' && expand && (
116
- <AnimatedRow key='inline-signup'>
117
- <SignUpFormInline key='signup-form-inline' email={watch('email')}>
118
- {children}
119
- </SignUpFormInline>
120
- </AnimatedRow>
121
- )}
122
-
123
- {mode === 'session-expired' && (
124
- <FormRow>
125
- <Alert severity='error'>
126
- <Trans id='You must sign in to continue' />
127
- </Alert>
128
- </FormRow>
129
- )}
130
- {children && mode !== 'session-expired' && ((mode !== 'signup' && expand) || !expand) && (
131
- <AnimatedRow key='email-helperlist'>{children}</AnimatedRow>
132
- )}
133
- </AnimatePresence>
134
- </FormDiv>
69
+ <form noValidate onSubmit={submit}>
70
+ <FormRow>
71
+ <Typography variant='h5' component='h2' gutterBottom>
72
+ <Trans id='Personal details' />
73
+ </Typography>
74
+ </FormRow>
75
+ <FormRow className={classes.formRow} sx={{ py: 0 }}>
76
+ <TextField
77
+ variant='outlined'
78
+ type='email'
79
+ error={formState.isSubmitted && !!formState.errors.email}
80
+ helperText={formState.isSubmitted && formState.errors.email?.message}
81
+ label={<Trans id='Email' />}
82
+ required={required.email}
83
+ {...muiRegister('email', {
84
+ required: required.email,
85
+ pattern: { value: emailPattern, message: '' },
86
+ })}
87
+ InputProps={{
88
+ autoComplete: 'email',
89
+ endAdornment,
90
+ readOnly: mode === 'signedin' || mode === 'session-expired',
91
+ }}
92
+ />
93
+ </FormRow>
94
+ <ApolloCartErrorAlert error={error} />
95
+ </form>
135
96
  )
136
97
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-cart-email",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "3.0.21",
5
+ "version": "3.0.24",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -19,12 +19,12 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@graphcommerce/graphql": "3.1.3",
22
- "@graphcommerce/image": "3.1.5",
23
- "@graphcommerce/magento-cart": "4.3.0",
24
- "@graphcommerce/magento-customer": "4.3.1",
25
- "@graphcommerce/magento-product": "4.3.6",
26
- "@graphcommerce/magento-store": "4.2.4",
27
- "@graphcommerce/next-ui": "4.8.0",
22
+ "@graphcommerce/image": "3.1.6",
23
+ "@graphcommerce/magento-cart": "4.3.3",
24
+ "@graphcommerce/magento-customer": "4.4.1",
25
+ "@graphcommerce/magento-product": "4.4.2",
26
+ "@graphcommerce/magento-store": "4.2.7",
27
+ "@graphcommerce/next-ui": "4.8.3",
28
28
  "@graphcommerce/react-hook-form": "3.1.3"
29
29
  },
30
30
  "peerDependencies": {