@graphcommerce/magento-newsletter 2.1.8 → 2.2.1
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,27 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`ad63ebf4e`](https://github.com/graphcommerce-org/graphcommerce/commit/ad63ebf4e33bfb0e5c9e5e68ab69b14775f3f8a8)]:
|
|
8
|
+
- @graphcommerce/next-ui@4.27.0
|
|
9
|
+
- @graphcommerce/magento-cart@4.8.4
|
|
10
|
+
- @graphcommerce/magento-customer@4.11.4
|
|
11
|
+
|
|
12
|
+
## 2.2.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#1645](https://github.com/graphcommerce-org/graphcommerce/pull/1645) [`f0ddcb868`](https://github.com/graphcommerce-org/graphcommerce/commit/f0ddcb86815d0525842c79a168c08e99f5799c76) Thanks [@Jessevdpoel](https://github.com/Jessevdpoel)! - Added Subscribe to newsletter checkbox
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`42e7fac75`](https://github.com/graphcommerce-org/graphcommerce/commit/42e7fac75712f9bda7a6b919ede14b3c75d07771)]:
|
|
21
|
+
- @graphcommerce/next-ui@4.26.0
|
|
22
|
+
- @graphcommerce/magento-cart@4.8.3
|
|
23
|
+
- @graphcommerce/magento-customer@4.11.3
|
|
24
|
+
|
|
3
25
|
## 2.1.8
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CheckboxElement, useFormCompose } from '@graphcommerce/ecommerce-ui'
|
|
2
|
+
import { DocumentNode } from '@graphcommerce/graphql'
|
|
3
|
+
import { useCartQuery } from '@graphcommerce/magento-cart'
|
|
4
|
+
import { useCustomerQuery, useCustomerSession } from '@graphcommerce/magento-customer'
|
|
5
|
+
import { useFormGql, useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
6
|
+
import { Box, SxProps, Theme } from '@mui/material'
|
|
7
|
+
import { GetCustomerNewsletterToggleDocument } from '../CustomerNewsletterToggle/GetCustomerNewsLetterToggle.gql'
|
|
8
|
+
import { GetCartEmailDocument } from '../SignupNewsletter/GetCartEmail.gql'
|
|
9
|
+
import { SubscribeCustomerDocument } from './SubscribeCustomer.gql'
|
|
10
|
+
import {
|
|
11
|
+
SubscribeGuestDocument,
|
|
12
|
+
SubscribeGuestMutation,
|
|
13
|
+
SubscribeGuestMutationVariables,
|
|
14
|
+
} from './SubscribeGuest.gql'
|
|
15
|
+
|
|
16
|
+
type CheckoutNewsletterProps = {
|
|
17
|
+
step: number
|
|
18
|
+
checked?: boolean
|
|
19
|
+
label: string
|
|
20
|
+
sx?: SxProps<Theme>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function SubscribeToNewsletter(props: CheckoutNewsletterProps) {
|
|
24
|
+
const { step, checked = false, label, sx } = props
|
|
25
|
+
const cartEmail = useCartQuery(GetCartEmailDocument).data?.cart?.email
|
|
26
|
+
|
|
27
|
+
const { loggedIn } = useCustomerSession()
|
|
28
|
+
const isCustomerSubscribed = useCustomerQuery(GetCustomerNewsletterToggleDocument).data?.customer
|
|
29
|
+
?.is_subscribed
|
|
30
|
+
|
|
31
|
+
const form = useFormGqlMutation<
|
|
32
|
+
SubscribeGuestMutation,
|
|
33
|
+
SubscribeGuestMutationVariables & { subscribe: boolean }
|
|
34
|
+
>(
|
|
35
|
+
loggedIn ? (SubscribeCustomerDocument as DocumentNode) : SubscribeGuestDocument,
|
|
36
|
+
{
|
|
37
|
+
defaultValues: { subscribe: checked },
|
|
38
|
+
onBeforeSubmit: ({ subscribe }) =>
|
|
39
|
+
subscribe ? { subscribe, email: cartEmail ?? '' } : false,
|
|
40
|
+
},
|
|
41
|
+
{ errorPolicy: 'all' },
|
|
42
|
+
)
|
|
43
|
+
const { control, handleSubmit } = form
|
|
44
|
+
const submit = handleSubmit(() => {})
|
|
45
|
+
|
|
46
|
+
useFormCompose({ form, step, submit, key: 'NewsletterSubscribeForm' })
|
|
47
|
+
|
|
48
|
+
if (isCustomerSubscribed) return null
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Box sx={sx}>
|
|
52
|
+
<form onSubmit={submit} noValidate>
|
|
53
|
+
<CheckboxElement color='secondary' control={control} name='subscribe' label={label} />
|
|
54
|
+
</form>
|
|
55
|
+
</Box>
|
|
56
|
+
)
|
|
57
|
+
}
|
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": "2.1
|
|
5
|
+
"version": "2.2.1",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@graphcommerce/graphql": "3.4.8",
|
|
22
|
-
"@graphcommerce/magento-cart": "4.8.
|
|
23
|
-
"@graphcommerce/magento-customer": "4.11.
|
|
24
|
-
"@graphcommerce/next-ui": "4.
|
|
22
|
+
"@graphcommerce/magento-cart": "4.8.4",
|
|
23
|
+
"@graphcommerce/magento-customer": "4.11.4",
|
|
24
|
+
"@graphcommerce/next-ui": "4.27.0",
|
|
25
25
|
"@graphcommerce/react-hook-form": "3.3.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|