@graphcommerce/magento-newsletter 6.2.0-canary.47 → 6.2.0-canary.49
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 6.2.0-canary.49
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#1959](https://github.com/graphcommerce-org/graphcommerce/pull/1959) [`f164217af`](https://github.com/graphcommerce-org/graphcommerce/commit/f164217af6847cff8555e19e7fc25f03528144e5) - Moved the GuestNewsletter component to inside the magento-newsletter package ([@JoshuaS98](https://github.com/JoshuaS98))
|
8
|
+
|
9
|
+
## 6.2.0-canary.48
|
10
|
+
|
3
11
|
## 6.2.0-canary.47
|
4
12
|
|
5
13
|
## 6.2.0-canary.46
|
@@ -2,7 +2,7 @@ import { CheckboxElement, useFormCompose } from '@graphcommerce/ecommerce-ui'
|
|
2
2
|
import { DocumentNode } from '@graphcommerce/graphql'
|
3
3
|
import { useCartQuery } from '@graphcommerce/magento-cart'
|
4
4
|
import { useCustomerQuery, useCustomerSession } from '@graphcommerce/magento-customer'
|
5
|
-
import {
|
5
|
+
import { useFormGqlMutation, useFormPersist } from '@graphcommerce/react-hook-form'
|
6
6
|
import { Box, SxProps, Theme } from '@mui/material'
|
7
7
|
import { GetCustomerNewsletterToggleDocument } from '../CustomerNewsletterToggle/GetCustomerNewsLetterToggle.gql'
|
8
8
|
import { GetCartEmailDocument } from '../SignupNewsletter/GetCartEmail.gql'
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import {
|
2
|
+
ApolloErrorSnackbar,
|
3
|
+
TextFieldElement,
|
4
|
+
useFormGqlMutation,
|
5
|
+
} from '@graphcommerce/ecommerce-ui'
|
6
|
+
import { Form, MessageSnackbar, Button } from '@graphcommerce/next-ui'
|
7
|
+
import { i18n } from '@lingui/core'
|
8
|
+
import { Trans } from '@lingui/react'
|
9
|
+
import { SxProps, Theme } from '@mui/material'
|
10
|
+
import { GuestNewsletterToggleDocument } from '../GuestNewsletterToggle/GuestNewsletterToggle.gql'
|
11
|
+
|
12
|
+
type GuestNewsletterProps = {
|
13
|
+
sx?: SxProps<Theme>
|
14
|
+
}
|
15
|
+
|
16
|
+
export function GuestNewsletter(props: GuestNewsletterProps) {
|
17
|
+
const { sx = [] } = props
|
18
|
+
const form = useFormGqlMutation(GuestNewsletterToggleDocument, {}, { errorPolicy: 'all' })
|
19
|
+
|
20
|
+
const { handleSubmit, formState, error, control } = form
|
21
|
+
const submit = handleSubmit(() => {})
|
22
|
+
|
23
|
+
const submittedWithoutErrors = formState.isSubmitSuccessful && !error
|
24
|
+
|
25
|
+
return (
|
26
|
+
<Form
|
27
|
+
noValidate
|
28
|
+
onSubmit={submit}
|
29
|
+
sx={[(theme) => ({ gap: theme.spacings.xs }), ...(Array.isArray(sx) ? sx : [sx])]}
|
30
|
+
>
|
31
|
+
<TextFieldElement
|
32
|
+
required
|
33
|
+
variant='outlined'
|
34
|
+
type='email'
|
35
|
+
label={i18n._(/* i18n */ 'Email address')}
|
36
|
+
control={control}
|
37
|
+
name='email'
|
38
|
+
size='medium'
|
39
|
+
inputProps={{ autoComplete: 'email' }}
|
40
|
+
disabled={submittedWithoutErrors}
|
41
|
+
/>
|
42
|
+
|
43
|
+
<Button
|
44
|
+
loading={formState.isSubmitting}
|
45
|
+
variant='pill'
|
46
|
+
color='primary'
|
47
|
+
type='submit'
|
48
|
+
size='large'
|
49
|
+
disabled={submittedWithoutErrors}
|
50
|
+
>
|
51
|
+
{submittedWithoutErrors ? <Trans id='Subscribed' /> : <Trans id='Subscribe' />}
|
52
|
+
</Button>
|
53
|
+
|
54
|
+
<MessageSnackbar
|
55
|
+
open={submittedWithoutErrors}
|
56
|
+
variant='pill'
|
57
|
+
action={
|
58
|
+
<Button size='medium' variant='pill' color='secondary' fullWidth>
|
59
|
+
<Trans id='Ok' />
|
60
|
+
</Button>
|
61
|
+
}
|
62
|
+
>
|
63
|
+
<Trans id='You have been successfully subscribed to our newsletter.' />
|
64
|
+
</MessageSnackbar>
|
65
|
+
|
66
|
+
<ApolloErrorSnackbar error={error} />
|
67
|
+
</Form>
|
68
|
+
)
|
69
|
+
}
|
package/components/index.ts
CHANGED
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@graphcommerce/magento-newsletter",
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
5
|
-
"version": "6.2.0-canary.
|
5
|
+
"version": "6.2.0-canary.49",
|
6
6
|
"sideEffects": false,
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
8
8
|
"eslintConfig": {
|
@@ -12,16 +12,17 @@
|
|
12
12
|
}
|
13
13
|
},
|
14
14
|
"devDependencies": {
|
15
|
-
"@graphcommerce/eslint-config-pwa": "6.2.0-canary.
|
16
|
-
"@graphcommerce/prettier-config-pwa": "6.2.0-canary.
|
17
|
-
"@graphcommerce/typescript-config-pwa": "6.2.0-canary.
|
15
|
+
"@graphcommerce/eslint-config-pwa": "6.2.0-canary.49",
|
16
|
+
"@graphcommerce/prettier-config-pwa": "6.2.0-canary.49",
|
17
|
+
"@graphcommerce/typescript-config-pwa": "6.2.0-canary.49"
|
18
18
|
},
|
19
19
|
"dependencies": {
|
20
|
-
"@graphcommerce/
|
21
|
-
"@graphcommerce/
|
22
|
-
"@graphcommerce/magento-
|
23
|
-
"@graphcommerce/
|
24
|
-
"@graphcommerce/
|
20
|
+
"@graphcommerce/ecommerce-ui": "6.2.0-canary.49",
|
21
|
+
"@graphcommerce/graphql": "6.2.0-canary.49",
|
22
|
+
"@graphcommerce/magento-cart": "6.2.0-canary.49",
|
23
|
+
"@graphcommerce/magento-customer": "6.2.0-canary.49",
|
24
|
+
"@graphcommerce/next-ui": "6.2.0-canary.49",
|
25
|
+
"@graphcommerce/react-hook-form": "6.2.0-canary.49"
|
25
26
|
},
|
26
27
|
"peerDependencies": {
|
27
28
|
"@lingui/react": "^4.2.1",
|