@graphcommerce/magento-cart-shipping-address 7.0.0-canary.21 → 7.0.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.
- package/CHANGELOG.md +183 -1
- package/components/CustomerAddressForm/CustomerAddressActionCard.tsx +2 -2
- package/components/CustomerAddressForm/CustomerAddressForm.tsx +19 -19
- package/components/ShippingAddressForm/ShippingAddressForm.tsx +1 -0
- package/package.json +14 -13
- package/test/fillShippingAddressForm.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,188 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 7.0.0
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2021](https://github.com/graphcommerce-org/graphcommerce/pull/2021) [`06ab7d24d`](https://github.com/graphcommerce-org/graphcommerce/commit/06ab7d24dcf345c6acd39471df544a726a166ece) - Ensure 'addition' parameter is non-empty in onBeforeSubmit ([@carlocarels90](https://github.com/carlocarels90))
|
|
8
|
+
|
|
9
|
+
- [#2006](https://github.com/graphcommerce-org/graphcommerce/pull/2006) [`80b60cb40`](https://github.com/graphcommerce-org/graphcommerce/commit/80b60cb404882260bd0e8184f3e54f4720925c96) - The Billing address was set to the shipping address when a default billing address was available and made prefix optional when creating an address ([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
10
|
+
|
|
11
|
+
- [#1987](https://github.com/graphcommerce-org/graphcommerce/pull/1987) [`96ac01045`](https://github.com/graphcommerce-org/graphcommerce/commit/96ac010454b57208ede11bf33d89b71b099a7bb3) - When there is a default_shipping address on the customer but not on the cart yet, make sure it gets submitted on load ([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
12
|
+
|
|
13
|
+
- [#2016](https://github.com/graphcommerce-org/graphcommerce/pull/2016) [`227ddcee8`](https://github.com/graphcommerce-org/graphcommerce/commit/227ddcee8808715928371c1f3a4c7925032df0ef) - Made cardProps on CustomerAddressActionCards overridable. ([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
14
|
+
|
|
15
|
+
## 6.2.0-canary.98
|
|
16
|
+
|
|
17
|
+
## 6.2.0-canary.97
|
|
18
|
+
|
|
19
|
+
## 6.2.0-canary.96
|
|
20
|
+
|
|
21
|
+
## 6.2.0-canary.95
|
|
22
|
+
|
|
23
|
+
## 6.2.0-canary.94
|
|
24
|
+
|
|
25
|
+
## 6.2.0-canary.93
|
|
26
|
+
|
|
27
|
+
## 6.2.0-canary.92
|
|
28
|
+
|
|
29
|
+
## 6.2.0-canary.91
|
|
30
|
+
|
|
31
|
+
## 6.2.0-canary.90
|
|
32
|
+
|
|
33
|
+
## 6.2.0-canary.89
|
|
34
|
+
|
|
35
|
+
## 6.2.0-canary.88
|
|
36
|
+
|
|
37
|
+
## 6.2.0-canary.87
|
|
38
|
+
|
|
39
|
+
## 6.2.0-canary.86
|
|
40
|
+
|
|
41
|
+
## 6.2.0-canary.85
|
|
42
|
+
|
|
43
|
+
## 6.2.0-canary.84
|
|
44
|
+
|
|
45
|
+
## 6.2.0-canary.83
|
|
46
|
+
|
|
47
|
+
## 6.2.0-canary.82
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- [#2021](https://github.com/graphcommerce-org/graphcommerce/pull/2021) [`06ab7d24d`](https://github.com/graphcommerce-org/graphcommerce/commit/06ab7d24dcf345c6acd39471df544a726a166ece) - Ensure 'addition' parameter is non-empty in onBeforeSubmit ([@carlocarels90](https://github.com/carlocarels90))
|
|
52
|
+
|
|
53
|
+
## 6.2.0-canary.81
|
|
54
|
+
|
|
55
|
+
## 6.2.0-canary.80
|
|
56
|
+
|
|
57
|
+
## 6.2.0-canary.79
|
|
58
|
+
|
|
59
|
+
## 6.2.0-canary.78
|
|
60
|
+
|
|
61
|
+
## 6.2.0-canary.77
|
|
62
|
+
|
|
63
|
+
## 6.2.0-canary.76
|
|
64
|
+
|
|
65
|
+
## 6.2.0-canary.75
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- [#2016](https://github.com/graphcommerce-org/graphcommerce/pull/2016) [`227ddcee8`](https://github.com/graphcommerce-org/graphcommerce/commit/227ddcee8808715928371c1f3a4c7925032df0ef) - Made cardProps on CustomerAddressActionCards overridable. ([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
70
|
+
|
|
71
|
+
## 6.2.0-canary.74
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- [#2006](https://github.com/graphcommerce-org/graphcommerce/pull/2006) [`80b60cb40`](https://github.com/graphcommerce-org/graphcommerce/commit/80b60cb404882260bd0e8184f3e54f4720925c96) - Bugfix for unintentionally overriding the billing address even if a default address was set. Also made prefix optional when creating an address ([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
76
|
+
|
|
77
|
+
## 6.2.0-canary.73
|
|
78
|
+
|
|
79
|
+
## 6.2.0-canary.72
|
|
80
|
+
|
|
81
|
+
## 6.2.0-canary.71
|
|
82
|
+
|
|
83
|
+
## 6.2.0-canary.70
|
|
84
|
+
|
|
85
|
+
## 6.2.0-canary.69
|
|
86
|
+
|
|
87
|
+
## 6.2.0-canary.68
|
|
88
|
+
|
|
89
|
+
## 6.2.0-canary.67
|
|
90
|
+
|
|
91
|
+
## 6.2.0-canary.66
|
|
92
|
+
|
|
93
|
+
## 6.2.0-canary.65
|
|
94
|
+
|
|
95
|
+
## 6.2.0-canary.64
|
|
96
|
+
|
|
97
|
+
## 6.2.0-canary.63
|
|
98
|
+
|
|
99
|
+
## 6.2.0-canary.62
|
|
100
|
+
|
|
101
|
+
## 6.2.0-canary.61
|
|
102
|
+
|
|
103
|
+
## 6.2.0-canary.60
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- [#1987](https://github.com/graphcommerce-org/graphcommerce/pull/1987) [`96ac01045`](https://github.com/graphcommerce-org/graphcommerce/commit/96ac010454b57208ede11bf33d89b71b099a7bb3) - When there is a default_shipping address on the customer, but it isn’t on the cart yet, When there is a default_shipping address on the customer, make sure it gets submitted on load ([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
108
|
+
|
|
109
|
+
## 6.2.0-canary.59
|
|
110
|
+
|
|
111
|
+
## 6.2.0-canary.58
|
|
112
|
+
|
|
113
|
+
## 6.2.0-canary.57
|
|
114
|
+
|
|
115
|
+
## 6.2.0-canary.56
|
|
116
|
+
|
|
117
|
+
## 6.2.0-canary.55
|
|
118
|
+
|
|
119
|
+
## 6.2.0-canary.54
|
|
120
|
+
|
|
121
|
+
## 6.2.0-canary.53
|
|
122
|
+
|
|
123
|
+
## 6.2.0-canary.52
|
|
124
|
+
|
|
125
|
+
## 6.2.0-canary.51
|
|
126
|
+
|
|
127
|
+
## 6.2.0-canary.50
|
|
128
|
+
|
|
129
|
+
## 6.2.0-canary.49
|
|
130
|
+
|
|
131
|
+
## 6.2.0-canary.48
|
|
132
|
+
|
|
133
|
+
## 6.2.0-canary.47
|
|
134
|
+
|
|
135
|
+
## 6.2.0-canary.46
|
|
136
|
+
|
|
137
|
+
## 6.2.0-canary.45
|
|
138
|
+
|
|
139
|
+
## 6.2.0-canary.44
|
|
140
|
+
|
|
141
|
+
## 6.2.0-canary.43
|
|
142
|
+
|
|
143
|
+
## 6.2.0-canary.42
|
|
144
|
+
|
|
145
|
+
## 6.2.0-canary.41
|
|
146
|
+
|
|
147
|
+
## 6.2.0-canary.40
|
|
148
|
+
|
|
149
|
+
## 6.2.0-canary.39
|
|
150
|
+
|
|
151
|
+
## 6.2.0-canary.38
|
|
152
|
+
|
|
153
|
+
## 6.2.0-canary.37
|
|
154
|
+
|
|
155
|
+
## 6.2.0-canary.36
|
|
156
|
+
|
|
157
|
+
## 6.2.0-canary.35
|
|
158
|
+
|
|
159
|
+
## 6.2.0-canary.34
|
|
160
|
+
|
|
161
|
+
## 6.2.0-canary.33
|
|
162
|
+
|
|
163
|
+
## 6.2.0-canary.32
|
|
164
|
+
|
|
165
|
+
## 6.2.0-canary.31
|
|
166
|
+
|
|
167
|
+
## 6.2.0-canary.30
|
|
168
|
+
|
|
169
|
+
## 6.2.0-canary.29
|
|
170
|
+
|
|
171
|
+
## 6.2.0-canary.28
|
|
172
|
+
|
|
173
|
+
## 6.2.0-canary.27
|
|
174
|
+
|
|
175
|
+
## 6.2.0-canary.26
|
|
176
|
+
|
|
177
|
+
## 6.2.0-canary.25
|
|
178
|
+
|
|
179
|
+
## 6.2.0-canary.24
|
|
180
|
+
|
|
181
|
+
## 6.2.0-canary.23
|
|
182
|
+
|
|
183
|
+
## 6.2.0-canary.22
|
|
184
|
+
|
|
185
|
+
## 6.2.0-canary.21
|
|
4
186
|
|
|
5
187
|
## 6.2.0-canary.20
|
|
6
188
|
|
|
@@ -29,7 +29,6 @@ export function CustomerAddressActionCard(props: CustomerAddressActionCardProps)
|
|
|
29
29
|
if (cardProps.value === -1) {
|
|
30
30
|
return (
|
|
31
31
|
<ActionCard
|
|
32
|
-
{...cardProps}
|
|
33
32
|
image={<IconSvg src={iconHome} size='large' />}
|
|
34
33
|
title={<Trans id='New address' />}
|
|
35
34
|
details={<Trans id='Add new address' />}
|
|
@@ -43,13 +42,13 @@ export function CustomerAddressActionCard(props: CustomerAddressActionCardProps)
|
|
|
43
42
|
<Trans id='Change' />
|
|
44
43
|
</Button>
|
|
45
44
|
}
|
|
45
|
+
{...cardProps}
|
|
46
46
|
/>
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
51
|
<ActionCard
|
|
52
|
-
{...cardProps}
|
|
53
52
|
image={<IconSvg src={iconHome} size='large' />}
|
|
54
53
|
title={
|
|
55
54
|
<>
|
|
@@ -89,6 +88,7 @@ export function CustomerAddressActionCard(props: CustomerAddressActionCardProps)
|
|
|
89
88
|
<Trans id='Edit address' />
|
|
90
89
|
</Button>
|
|
91
90
|
}
|
|
91
|
+
{...cardProps}
|
|
92
92
|
/>
|
|
93
93
|
)
|
|
94
94
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFormPersist,
|
|
3
|
+
useFormCompose,
|
|
4
|
+
UseFormComposeOptions,
|
|
5
|
+
useFormAutoSubmit,
|
|
6
|
+
} from '@graphcommerce/ecommerce-ui'
|
|
1
7
|
import { useQuery } from '@graphcommerce/graphql'
|
|
2
8
|
import {
|
|
3
9
|
ApolloCartErrorAlert,
|
|
@@ -6,14 +12,8 @@ import {
|
|
|
6
12
|
} from '@graphcommerce/magento-cart'
|
|
7
13
|
import { CustomerDocument } from '@graphcommerce/magento-customer'
|
|
8
14
|
import { ActionCardListForm } from '@graphcommerce/next-ui'
|
|
9
|
-
import {
|
|
10
|
-
useFormPersist,
|
|
11
|
-
useFormCompose,
|
|
12
|
-
UseFormComposeOptions,
|
|
13
|
-
useFormAutoSubmit,
|
|
14
|
-
} from '@graphcommerce/react-hook-form'
|
|
15
15
|
import { Box, SxProps, Theme } from '@mui/material'
|
|
16
|
-
import React
|
|
16
|
+
import React from 'react'
|
|
17
17
|
import { isSameAddress } from '../../utils/isSameAddress'
|
|
18
18
|
import { GetAddressesDocument } from '../ShippingAddressForm/GetAddresses.gql'
|
|
19
19
|
import { CustomerAddressActionCard } from './CustomerAddressActionCard'
|
|
@@ -33,8 +33,12 @@ export function CustomerAddressForm(props: CustomerAddressListProps) {
|
|
|
33
33
|
|
|
34
34
|
const { data: cartQuery } = useCartQuery(GetAddressesDocument)
|
|
35
35
|
|
|
36
|
+
const defaultBillingAddress = customerAddresses.data?.customer?.addresses?.find(
|
|
37
|
+
(a) => a?.default_billing,
|
|
38
|
+
)
|
|
39
|
+
|
|
36
40
|
const shippingAddress = cartQuery?.cart?.shipping_addresses?.[0]
|
|
37
|
-
const billingAddress = cartQuery?.cart?.billing_address
|
|
41
|
+
const billingAddress = defaultBillingAddress || cartQuery?.cart?.billing_address
|
|
38
42
|
|
|
39
43
|
const found = customerAddresses.data?.customer?.addresses?.find(
|
|
40
44
|
(customerAddr) =>
|
|
@@ -55,13 +59,16 @@ export function CustomerAddressForm(props: CustomerAddressListProps) {
|
|
|
55
59
|
? SetCustomerShippingBillingAddressOnCartDocument
|
|
56
60
|
: SetCustomerShippingAddressOnCartDocument
|
|
57
61
|
|
|
62
|
+
const defaultAddrId =
|
|
63
|
+
(!shippingAddress && addresses?.find((a) => a?.default_shipping)?.id) || undefined
|
|
64
|
+
|
|
58
65
|
// if (cartQuery?.cart?.is_virtual) {
|
|
59
66
|
// Mutation = SetCustomerBillingAddressOnCartDocument
|
|
60
67
|
// }
|
|
61
68
|
|
|
62
69
|
const form = useFormGqlMutationCart(Mutation, {
|
|
63
70
|
defaultValues: {
|
|
64
|
-
customerAddressId: found?.id ??
|
|
71
|
+
customerAddressId: found?.id ?? defaultAddrId,
|
|
65
72
|
},
|
|
66
73
|
onBeforeSubmit: (vars) => {
|
|
67
74
|
if (vars.customerAddressId === -1) return false
|
|
@@ -69,7 +76,7 @@ export function CustomerAddressForm(props: CustomerAddressListProps) {
|
|
|
69
76
|
},
|
|
70
77
|
})
|
|
71
78
|
|
|
72
|
-
const { handleSubmit, error, control, watch
|
|
79
|
+
const { handleSubmit, error, control, watch } = form
|
|
73
80
|
|
|
74
81
|
// If customer selects 'new address' then we do not have to submit anything so we provide an empty submit function.
|
|
75
82
|
const customerAddressId = watch('customerAddressId')
|
|
@@ -81,15 +88,8 @@ export function CustomerAddressForm(props: CustomerAddressListProps) {
|
|
|
81
88
|
useFormCompose({ form, step, submit, key: 'CustomerAddressForm' })
|
|
82
89
|
|
|
83
90
|
// We want to autosubmit the CustomerAddressFrom because the shipping methods depend on it.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// When there is no address set on the cart set before
|
|
87
|
-
const defaultAddr =
|
|
88
|
-
(!shippingAddress && addresses?.find((a) => a?.default_shipping)?.id) || undefined
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (defaultAddr) setValue('customerAddressId', defaultAddr)
|
|
92
|
-
}, [defaultAddr, setValue])
|
|
91
|
+
const forceInitialSubmit = found?.id === undefined && defaultAddrId !== undefined
|
|
92
|
+
useFormAutoSubmit({ form, submit, forceInitialSubmit })
|
|
93
93
|
|
|
94
94
|
if (customerAddresses.loading || !addresses || addresses.length === 0) return <>{children}</>
|
|
95
95
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-cart-shipping-address",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "7.0.0
|
|
5
|
+
"version": "7.0.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,22 +12,23 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "7.0.0
|
|
16
|
-
"@graphcommerce/prettier-config-pwa": "7.0.0
|
|
17
|
-
"@graphcommerce/typescript-config-pwa": "7.0.0
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "7.0.0",
|
|
16
|
+
"@graphcommerce/prettier-config-pwa": "7.0.0",
|
|
17
|
+
"@graphcommerce/typescript-config-pwa": "7.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@graphcommerce/ecommerce-ui": "7.0.0
|
|
21
|
-
"@graphcommerce/graphql": "7.0.0
|
|
22
|
-
"@graphcommerce/image": "7.0.0
|
|
23
|
-
"@graphcommerce/magento-cart": "7.0.0
|
|
24
|
-
"@graphcommerce/magento-customer": "7.0.0
|
|
25
|
-
"@graphcommerce/magento-store": "7.0.0
|
|
26
|
-
"@graphcommerce/next-ui": "7.0.0
|
|
20
|
+
"@graphcommerce/ecommerce-ui": "7.0.0",
|
|
21
|
+
"@graphcommerce/graphql": "7.0.0",
|
|
22
|
+
"@graphcommerce/image": "7.0.0",
|
|
23
|
+
"@graphcommerce/magento-cart": "7.0.0",
|
|
24
|
+
"@graphcommerce/magento-customer": "7.0.0",
|
|
25
|
+
"@graphcommerce/magento-store": "7.0.0",
|
|
26
|
+
"@graphcommerce/next-ui": "7.0.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@lingui/react": "^
|
|
30
|
-
"@lingui/core": "^
|
|
29
|
+
"@lingui/react": "^4.2.1",
|
|
30
|
+
"@lingui/core": "^4.2.1",
|
|
31
|
+
"@lingui/macro": "^4.2.1",
|
|
31
32
|
"@mui/material": "^5.10.16",
|
|
32
33
|
"framer-motion": "^10.0.0",
|
|
33
34
|
"next": "^13.2.0",
|