@graphcommerce/magento-cart-shipping-address 2.103.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.
@@ -0,0 +1,4 @@
1
+ /* eslint-disable */
2
+ import * as Types from '@graphcommerce/graphql';
3
+
4
+ export type BillingAddressFragment = { id: string, billing_address?: Types.Maybe<{ __typename: 'BillingCartAddress', firstname: string, lastname: string, city: string, company?: Types.Maybe<string>, postcode?: Types.Maybe<string>, street: Array<Types.Maybe<string>>, telephone: string, country: { code: string, label: string }, region?: Types.Maybe<{ code?: Types.Maybe<string>, label?: Types.Maybe<string>, region_id?: Types.Maybe<number> }> }> };
@@ -0,0 +1,6 @@
1
+ fragment BillingAddress on Cart @injectable {
2
+ id
3
+ billing_address {
4
+ ...CartAddress
5
+ }
6
+ }
@@ -0,0 +1,4 @@
1
+ /* eslint-disable */
2
+ import * as Types from '@graphcommerce/graphql';
3
+
4
+ export type ShippingAddressFragment = { id: string, shipping_addresses: Array<Types.Maybe<{ __typename: 'ShippingCartAddress', firstname: string, lastname: string, city: string, company?: Types.Maybe<string>, postcode?: Types.Maybe<string>, street: Array<Types.Maybe<string>>, telephone: string, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ available: boolean, carrier_code: string, carrier_title: string, error_message?: Types.Maybe<string>, method_code?: Types.Maybe<string>, method_title?: Types.Maybe<string>, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string }>, country: { code: string, label: string }, region?: Types.Maybe<{ code?: Types.Maybe<string>, label?: Types.Maybe<string>, region_id?: Types.Maybe<number> }> }>> };
@@ -0,0 +1,6 @@
1
+ fragment ShippingAddress on Cart @injectable {
2
+ id
3
+ shipping_addresses {
4
+ ...CartAddress
5
+ }
6
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,82 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [2.103.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-shipping-address@2.103.0...@graphcommerce/magento-cart-shipping-address@2.103.1) (2021-09-27)
7
+
8
+ **Note:** Version bump only for package @graphcommerce/magento-cart-shipping-address
9
+
10
+
11
+
12
+
13
+
14
+ # 2.103.0 (2021-09-27)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * add removed form import ([4bfea00](https://github.com/ho-nl/m2-pwa/commit/4bfea00038cebd50fb1bc6a123bc697ac582f06d))
20
+ * display empty country in country selector ([8b2a6a7](https://github.com/ho-nl/m2-pwa/commit/8b2a6a7af4ec1dec745dd96687712bc5a17b28d4))
21
+ * ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
22
+ * implement next-ui barrel imports ([75bea70](https://github.com/ho-nl/m2-pwa/commit/75bea703dba898f18a2a1dfa3243ebd0a4e6f0e1))
23
+ * make sure ComposedForm actually submits correctly ([c6499d9](https://github.com/ho-nl/m2-pwa/commit/c6499d9d36f874cd65b310cbf7f63f5a88fa86cd))
24
+
25
+
26
+ ### Features
27
+
28
+ * add barrel file for magento-customer ([02fb7f0](https://github.com/ho-nl/m2-pwa/commit/02fb7f004de968ee968b00e364b2b370f4f7d4f1))
29
+ * always use same shipping and billing address ([7b613bf](https://github.com/ho-nl/m2-pwa/commit/7b613bf569e69c76bcc4750943bf4adaa0132eb9))
30
+ * **cart:** when a cart is not active anymore show a clear cart button ([5d04a14](https://github.com/ho-nl/m2-pwa/commit/5d04a14726c040b20b34c0b88f923aee1dff22e5))
31
+ * **graphql:** introduced new graphql package that holds all generated files ([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
32
+ * **image:** introduced completely rewritten Image component ([e3413b3](https://github.com/ho-nl/m2-pwa/commit/e3413b3a57392d6571ea64cb8d9c8dca05ea31df))
33
+ * implemented purchase order ([3a40033](https://github.com/ho-nl/m2-pwa/commit/3a40033cd4d6712a17bb9c41a8841ebf7aa2f025))
34
+ * **next-ui:** SectionContainer/SectionHeader now accepts variantLeft/variantRight as prop ([a58f8f2](https://github.com/ho-nl/m2-pwa/commit/a58f8f2962e74c9aaa41142524d42d9c8f662b8d))
35
+ * next.js 11 ([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
36
+ * **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
37
+ * renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of [@reachdigital](https://github.com/reachdigital) ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
38
+ * submit composed form sequentially ([890d839](https://github.com/ho-nl/m2-pwa/commit/890d8393d635c3777aa17cfa8d4dafc13c2e6cdc))
39
+ * upgraded to nextjs 11 ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
40
+ * useFormMutationCart and simpler imports ([012f090](https://github.com/ho-nl/m2-pwa/commit/012f090e8f54d09f35d393c61ad1e2319f5a90ff))
41
+
42
+
43
+ ### Reverts
44
+
45
+ * Revert "chore: upgrade @apollo/client" ([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
46
+
47
+
48
+
49
+
50
+
51
+ # Change Log
52
+
53
+ All notable changes to this project will be documented in this file. See
54
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55
+
56
+ # [2.102.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-shipping-address@2.101.10...@graphcommerce/magento-cart-shipping-address@2.102.0) (2021-08-12)
57
+
58
+ ### Features
59
+
60
+ - upgraded to nextjs 11
61
+ ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
62
+
63
+ ## [2.101.9](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-shipping-address@2.101.8...@graphcommerce/magento-cart-shipping-address@2.101.9) (2021-08-09)
64
+
65
+ ### Reverts
66
+
67
+ - Revert "chore: upgrade @apollo/client"
68
+ ([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
69
+
70
+ # [2.101.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-shipping-address@2.100.19...@graphcommerce/magento-cart-shipping-address@2.101.0) (2021-07-26)
71
+
72
+ ### Features
73
+
74
+ - **playwright:** added new playwright package to enable browser testing
75
+ ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
76
+
77
+ ## [2.100.11](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-cart-shipping-address@2.100.10...@graphcommerce/magento-cart-shipping-address@2.100.11) (2021-07-20)
78
+
79
+ ### Bug Fixes
80
+
81
+ - ignore md files from triggering version updates
82
+ ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Magento Cart Shipping Address
2
+
3
+ ## Provides Injectables
4
+
5
+ - [`ShippingAddress`](./Injectable/ShippingAddress.graphql)
6
+
7
+ ## Injects into
8
+
9
+ - none
@@ -0,0 +1,12 @@
1
+ /* eslint-disable */
2
+ import * as Types from '@graphcommerce/graphql';
3
+
4
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
5
+
6
+ export const GetShippingAddressDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetShippingAddress"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"shipping_addresses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"available_shipping_methods"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"available"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_title"}},{"kind":"Field","name":{"kind":"Name","value":"error_message"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_title"}}]}},{"kind":"Field","name":{"kind":"Name","value":"selected_shipping_method"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"CartAddressInterface"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"firstname"}},{"kind":"Field","name":{"kind":"Name","value":"lastname"}},{"kind":"Field","name":{"kind":"Name","value":"city"}},{"kind":"Field","name":{"kind":"Name","value":"company"}},{"kind":"Field","name":{"kind":"Name","value":"country"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"postcode"}},{"kind":"Field","name":{"kind":"Name","value":"region"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"region_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"street"}},{"kind":"Field","name":{"kind":"Name","value":"telephone"}}]}}]}}]}}]}}]} as unknown as DocumentNode<GetShippingAddressQuery, GetShippingAddressQueryVariables>;
7
+ export type GetShippingAddressQueryVariables = Types.Exact<{
8
+ cartId: Types.Scalars['String'];
9
+ }>;
10
+
11
+
12
+ export type GetShippingAddressQuery = { cart?: Types.Maybe<{ id: string, shipping_addresses: Array<Types.Maybe<{ __typename: 'ShippingCartAddress', firstname: string, lastname: string, city: string, company?: Types.Maybe<string>, postcode?: Types.Maybe<string>, street: Array<Types.Maybe<string>>, telephone: string, country: { code: string, label: string }, region?: Types.Maybe<{ code?: Types.Maybe<string>, label?: Types.Maybe<string>, region_id?: Types.Maybe<number> }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ available: boolean, carrier_code: string, carrier_title: string, error_message?: Types.Maybe<string>, method_code?: Types.Maybe<string>, method_title?: Types.Maybe<string>, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string }> }>> }> };
@@ -0,0 +1,5 @@
1
+ query GetShippingAddress($cartId: String!) {
2
+ cart(cart_id: $cartId) {
3
+ ...ShippingAddress
4
+ }
5
+ }
@@ -0,0 +1,25 @@
1
+ /* eslint-disable */
2
+ import * as Types from '@graphcommerce/graphql';
3
+
4
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
5
+
6
+ export const ShippingAddressFormDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ShippingAddressForm"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"company"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"firstname"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"lastname"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"postcode"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"city"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"countryCode"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"street"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"houseNumber"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"addition"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"telephone"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}},"defaultValue":{"kind":"StringValue","value":"000 - 000 0000","block":false}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"saveInAddressBook"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"customerNote"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"setShippingAddressesOnCart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"shipping_addresses"},"value":{"kind":"ListValue","values":[{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"address"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"company"},"value":{"kind":"Variable","name":{"kind":"Name","value":"company"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"firstname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"firstname"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"lastname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"lastname"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"postcode"},"value":{"kind":"Variable","name":{"kind":"Name","value":"postcode"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"city"},"value":{"kind":"Variable","name":{"kind":"Name","value":"city"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"country_code"},"value":{"kind":"Variable","name":{"kind":"Name","value":"countryCode"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"region_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"street"},"value":{"kind":"ListValue","values":[{"kind":"Variable","name":{"kind":"Name","value":"street"}},{"kind":"Variable","name":{"kind":"Name","value":"houseNumber"}},{"kind":"Variable","name":{"kind":"Name","value":"addition"}}]}},{"kind":"ObjectField","name":{"kind":"Name","value":"telephone"},"value":{"kind":"Variable","name":{"kind":"Name","value":"telephone"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"save_in_address_book"},"value":{"kind":"Variable","name":{"kind":"Name","value":"saveInAddressBook"}}}]}},{"kind":"ObjectField","name":{"kind":"Name","value":"customer_notes"},"value":{"kind":"Variable","name":{"kind":"Name","value":"customerNote"}}}]}]}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"shipping_addresses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"available_shipping_methods"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"available"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_title"}},{"kind":"Field","name":{"kind":"Name","value":"error_message"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_title"}}]}},{"kind":"Field","name":{"kind":"Name","value":"selected_shipping_method"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"CartAddressInterface"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"firstname"}},{"kind":"Field","name":{"kind":"Name","value":"lastname"}},{"kind":"Field","name":{"kind":"Name","value":"city"}},{"kind":"Field","name":{"kind":"Name","value":"company"}},{"kind":"Field","name":{"kind":"Name","value":"country"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"postcode"}},{"kind":"Field","name":{"kind":"Name","value":"region"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"region_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"street"}},{"kind":"Field","name":{"kind":"Name","value":"telephone"}}]}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"setBillingAddressOnCart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"billing_address"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"address"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"company"},"value":{"kind":"Variable","name":{"kind":"Name","value":"company"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"firstname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"firstname"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"lastname"},"value":{"kind":"Variable","name":{"kind":"Name","value":"lastname"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"postcode"},"value":{"kind":"Variable","name":{"kind":"Name","value":"postcode"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"city"},"value":{"kind":"Variable","name":{"kind":"Name","value":"city"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"country_code"},"value":{"kind":"Variable","name":{"kind":"Name","value":"countryCode"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"region_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"street"},"value":{"kind":"ListValue","values":[{"kind":"Variable","name":{"kind":"Name","value":"street"}},{"kind":"Variable","name":{"kind":"Name","value":"houseNumber"}},{"kind":"Variable","name":{"kind":"Name","value":"addition"}}]}},{"kind":"ObjectField","name":{"kind":"Name","value":"telephone"},"value":{"kind":"Variable","name":{"kind":"Name","value":"telephone"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"save_in_address_book"},"value":{"kind":"Variable","name":{"kind":"Name","value":"saveInAddressBook"}}}]}},{"kind":"ObjectField","name":{"kind":"Name","value":"same_as_shipping"},"value":{"kind":"BooleanValue","value":true}}]}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"billing_address"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"CartAddressInterface"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"firstname"}},{"kind":"Field","name":{"kind":"Name","value":"lastname"}},{"kind":"Field","name":{"kind":"Name","value":"city"}},{"kind":"Field","name":{"kind":"Name","value":"company"}},{"kind":"Field","name":{"kind":"Name","value":"country"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"postcode"}},{"kind":"Field","name":{"kind":"Name","value":"region"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"region_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"street"}},{"kind":"Field","name":{"kind":"Name","value":"telephone"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ShippingAddressFormMutation, ShippingAddressFormMutationVariables>;
7
+ export type ShippingAddressFormMutationVariables = Types.Exact<{
8
+ cartId: Types.Scalars['String'];
9
+ company?: Types.Maybe<Types.Scalars['String']>;
10
+ firstname: Types.Scalars['String'];
11
+ lastname: Types.Scalars['String'];
12
+ postcode: Types.Scalars['String'];
13
+ city: Types.Scalars['String'];
14
+ countryCode: Types.Scalars['String'];
15
+ regionId?: Types.Maybe<Types.Scalars['Int']>;
16
+ street: Types.Scalars['String'];
17
+ houseNumber: Types.Scalars['String'];
18
+ addition?: Types.Maybe<Types.Scalars['String']>;
19
+ telephone?: Types.Maybe<Types.Scalars['String']>;
20
+ saveInAddressBook: Types.Scalars['Boolean'];
21
+ customerNote?: Types.Maybe<Types.Scalars['String']>;
22
+ }>;
23
+
24
+
25
+ export type ShippingAddressFormMutation = { setShippingAddressesOnCart?: Types.Maybe<{ cart: { __typename: 'Cart', id: string, shipping_addresses: Array<Types.Maybe<{ __typename: 'ShippingCartAddress', firstname: string, lastname: string, city: string, company?: Types.Maybe<string>, postcode?: Types.Maybe<string>, street: Array<Types.Maybe<string>>, telephone: string, country: { code: string, label: string }, region?: Types.Maybe<{ code?: Types.Maybe<string>, label?: Types.Maybe<string>, region_id?: Types.Maybe<number> }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ available: boolean, carrier_code: string, carrier_title: string, error_message?: Types.Maybe<string>, method_code?: Types.Maybe<string>, method_title?: Types.Maybe<string>, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string }> }>> } }>, setBillingAddressOnCart?: Types.Maybe<{ cart: { __typename: 'Cart', id: string, billing_address?: Types.Maybe<{ __typename: 'BillingCartAddress', firstname: string, lastname: string, city: string, company?: Types.Maybe<string>, postcode?: Types.Maybe<string>, street: Array<Types.Maybe<string>>, telephone: string, country: { code: string, label: string }, region?: Types.Maybe<{ code?: Types.Maybe<string>, label?: Types.Maybe<string>, region_id?: Types.Maybe<number> }> }> } }> };
@@ -0,0 +1,72 @@
1
+ mutation ShippingAddressForm(
2
+ $cartId: String!
3
+ $company: String
4
+ $firstname: String!
5
+ $lastname: String!
6
+ $postcode: String!
7
+ $city: String!
8
+ $countryCode: String!
9
+ $regionId: Int
10
+ $street: String!
11
+ $houseNumber: String!
12
+ $addition: String
13
+ $telephone: String = "000 - 000 0000"
14
+ $saveInAddressBook: Boolean!
15
+ $customerNote: String
16
+ ) {
17
+ setShippingAddressesOnCart(
18
+ input: {
19
+ cart_id: $cartId
20
+ shipping_addresses: [
21
+ {
22
+ address: {
23
+ company: $company
24
+ firstname: $firstname
25
+ lastname: $lastname
26
+ postcode: $postcode
27
+ city: $city
28
+ country_code: $countryCode
29
+ region_id: $regionId
30
+ street: [$street, $houseNumber, $addition]
31
+ telephone: $telephone
32
+ save_in_address_book: $saveInAddressBook
33
+ }
34
+ customer_notes: $customerNote
35
+ }
36
+ ]
37
+ }
38
+ ) {
39
+ cart {
40
+ id
41
+ __typename
42
+ ...ShippingAddress
43
+ }
44
+ }
45
+
46
+ setBillingAddressOnCart(
47
+ input: {
48
+ cart_id: $cartId
49
+ billing_address: {
50
+ address: {
51
+ company: $company
52
+ firstname: $firstname
53
+ lastname: $lastname
54
+ postcode: $postcode
55
+ city: $city
56
+ country_code: $countryCode
57
+ region_id: $regionId
58
+ street: [$street, $houseNumber, $addition]
59
+ telephone: $telephone
60
+ save_in_address_book: $saveInAddressBook
61
+ }
62
+ same_as_shipping: true
63
+ }
64
+ }
65
+ ) {
66
+ cart {
67
+ id
68
+ __typename
69
+ ...BillingAddress
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,111 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { TextField } from '@material-ui/core'
3
+ import {
4
+ useCartQuery,
5
+ useFormGqlMutationCart,
6
+ ApolloCartErrorAlert,
7
+ } from '@graphcommerce/magento-cart'
8
+ import { AddressFields, CustomerDocument, NameFields } from '@graphcommerce/magento-customer'
9
+ import { StoreConfigDocument, CountryRegionsDocument } from '@graphcommerce/magento-store'
10
+ import { Form, FormRow, InputCheckmark } from '@graphcommerce/next-ui'
11
+ import {
12
+ phonePattern,
13
+ useFormAutoSubmit,
14
+ useFormCompose,
15
+ UseFormComposeOptions,
16
+ useFormPersist,
17
+ } from '@graphcommerce/react-hook-form'
18
+ import { AnimatePresence } from 'framer-motion'
19
+ import React, { useRef } from 'react'
20
+ import { GetShippingAddressDocument } from './GetShippingAddress.gql'
21
+ import { ShippingAddressFormDocument } from './ShippingAddressForm.gql'
22
+
23
+ export type ShippingAddressFormProps = Pick<UseFormComposeOptions, 'step'>
24
+
25
+ export default function ShippingAddressForm(props: ShippingAddressFormProps) {
26
+ const { step } = props
27
+ const ref = useRef<HTMLFormElement>(null)
28
+ const { data: cartQuery } = useCartQuery(GetShippingAddressDocument)
29
+ const { data: config } = useQuery(StoreConfigDocument)
30
+ const { data: countriesData } = useQuery(CountryRegionsDocument)
31
+ const { data: customerQuery } = useQuery(CustomerDocument, { fetchPolicy: 'cache-only' })
32
+
33
+ const shopCountry = config?.storeConfig?.locale?.split('_')?.[1].toUpperCase()
34
+
35
+ const currentAddress = cartQuery?.cart?.shipping_addresses?.[0]
36
+ const currentCustomer = customerQuery?.customer
37
+ const currentCountryCode = currentAddress?.country.code ?? shopCountry
38
+
39
+ const form = useFormGqlMutationCart(ShippingAddressFormDocument, {
40
+ defaultValues: {
41
+ // todo(paales): change to something more sustainable
42
+ firstname: currentAddress?.firstname ?? currentCustomer?.firstname ?? '',
43
+ lastname: currentAddress?.lastname ?? currentCustomer?.lastname ?? '',
44
+ telephone: currentAddress?.telephone !== '000 - 000 0000' ? currentAddress?.telephone : '',
45
+ city: currentAddress?.city ?? '',
46
+ company: currentAddress?.company ?? '',
47
+ postcode: currentAddress?.postcode ?? '',
48
+ street: currentAddress?.street?.[0] ?? '',
49
+ houseNumber: currentAddress?.street?.[1] ?? '',
50
+ addition: currentAddress?.street?.[2] ?? '',
51
+ regionId: currentAddress?.region?.region_id ?? null,
52
+ countryCode: currentCountryCode, // todo: replace by the default shipping country of the store + geoip,
53
+ saveInAddressBook: true,
54
+ },
55
+ mode: 'onChange',
56
+ onBeforeSubmit: (variables) => {
57
+ const regionId = countriesData?.countries
58
+ ?.find((country) => country?.two_letter_abbreviation === variables.countryCode)
59
+ ?.available_regions?.find((region) => region?.id === variables.regionId)?.id
60
+
61
+ return {
62
+ ...variables,
63
+ telephone: variables.telephone || '000 - 000 0000',
64
+ regionId,
65
+ customerNote: '',
66
+ }
67
+ },
68
+ })
69
+ const { muiRegister, handleSubmit, valid, formState, required, error } = form
70
+ const submit = handleSubmit(() => {})
71
+
72
+ useFormPersist({ form, name: 'ShippingAddressForm' })
73
+ useFormCompose({ form, step, submit, key: 'ShippingAddressForm' })
74
+
75
+ const autoSubmitting = useFormAutoSubmit({
76
+ form,
77
+ submit,
78
+ fields: ['postcode', 'countryCode', 'regionId'],
79
+ })
80
+ const readOnly = formState.isSubmitting && !autoSubmitting
81
+
82
+ return (
83
+ <Form onSubmit={submit} noValidate ref={ref}>
84
+ <AnimatePresence initial={false}>
85
+ <NameFields form={form} key='name' readOnly={readOnly} />
86
+ <AddressFields form={form} key='addressfields' readOnly={readOnly} />
87
+
88
+ <FormRow key='telephone'>
89
+ <TextField
90
+ variant='outlined'
91
+ type='text'
92
+ error={!!formState.errors.telephone}
93
+ required={required.telephone}
94
+ label='Telephone'
95
+ {...muiRegister('telephone', {
96
+ required: required.telephone,
97
+ pattern: { value: phonePattern, message: 'Invalid phone number' },
98
+ })}
99
+ helperText={formState.isSubmitted && formState.errors.telephone?.message}
100
+ InputProps={{
101
+ readOnly,
102
+ endAdornment: <InputCheckmark show={valid.telephone} />,
103
+ }}
104
+ />
105
+ </FormRow>
106
+
107
+ <ApolloCartErrorAlert error={error} />
108
+ </AnimatePresence>
109
+ </Form>
110
+ )
111
+ }
@@ -0,0 +1,13 @@
1
+ /* eslint-disable */
2
+ import * as Types from '@graphcommerce/graphql';
3
+
4
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
5
+
6
+ export const ShippingAddressIdFormDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ShippingAddressIdForm"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"addressId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"setShippingAddressesOnCart"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"cart_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"cartId"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"shipping_addresses"},"value":{"kind":"ListValue","values":[{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"customer_address_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"addressId"}}}]}]}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cart"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"shipping_addresses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"available_shipping_methods"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}},{"kind":"Field","name":{"kind":"Name","value":"available"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"carrier_title"}},{"kind":"Field","name":{"kind":"Name","value":"error_message"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_title"}}]}},{"kind":"Field","name":{"kind":"Name","value":"selected_shipping_method"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"carrier_code"}},{"kind":"Field","name":{"kind":"Name","value":"method_code"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"CartAddressInterface"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"firstname"}},{"kind":"Field","name":{"kind":"Name","value":"lastname"}},{"kind":"Field","name":{"kind":"Name","value":"city"}},{"kind":"Field","name":{"kind":"Name","value":"company"}},{"kind":"Field","name":{"kind":"Name","value":"country"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}},{"kind":"Field","name":{"kind":"Name","value":"postcode"}},{"kind":"Field","name":{"kind":"Name","value":"region"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"region_id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"street"}},{"kind":"Field","name":{"kind":"Name","value":"telephone"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ShippingAddressIdFormMutation, ShippingAddressIdFormMutationVariables>;
7
+ export type ShippingAddressIdFormMutationVariables = Types.Exact<{
8
+ cartId: Types.Scalars['String'];
9
+ addressId: Types.Scalars['Int'];
10
+ }>;
11
+
12
+
13
+ export type ShippingAddressIdFormMutation = { setShippingAddressesOnCart?: Types.Maybe<{ cart: { id: string, shipping_addresses: Array<Types.Maybe<{ __typename: 'ShippingCartAddress', firstname: string, lastname: string, city: string, company?: Types.Maybe<string>, postcode?: Types.Maybe<string>, street: Array<Types.Maybe<string>>, telephone: string, country: { code: string, label: string }, region?: Types.Maybe<{ code?: Types.Maybe<string>, label?: Types.Maybe<string>, region_id?: Types.Maybe<number> }>, available_shipping_methods?: Types.Maybe<Array<Types.Maybe<{ available: boolean, carrier_code: string, carrier_title: string, error_message?: Types.Maybe<string>, method_code?: Types.Maybe<string>, method_title?: Types.Maybe<string>, amount: { currency?: Types.Maybe<Types.CurrencyEnum>, value?: Types.Maybe<number> } }>>>, selected_shipping_method?: Types.Maybe<{ carrier_code: string, method_code: string }> }>> } }> };
@@ -0,0 +1,9 @@
1
+ mutation ShippingAddressIdForm($cartId: String!, $addressId: Int!) {
2
+ setShippingAddressesOnCart(
3
+ input: { cart_id: $cartId, shipping_addresses: [{ customer_address_id: $addressId }] }
4
+ ) {
5
+ cart {
6
+ ...ShippingAddress
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,22 @@
1
+ import { Page } from '@playwright/test'
2
+
3
+ export async function fillShippingAddressForm(page: Page) {
4
+ await page.click('input[name="firstname"]')
5
+ await page.fill('input[name="firstname"]', 'Test')
6
+ await page.click('input[name="lastname"]')
7
+ await page.fill('input[name="lastname"]', 'Account')
8
+ await page.click('input[name="street"]')
9
+ await page.fill('input[name="street"]', 'Street')
10
+ await page.press('input[name="street"]', 'Tab')
11
+ await page.fill('input[name="houseNumber"]', '1')
12
+ await page.press('input[name="houseNumber"]', 'Tab')
13
+ await page.press('input[name="addition"]', 'Tab')
14
+ await page.fill('input[name="postcode"]', '1234AB')
15
+ await page.press('input[name="postcode"]', 'Tab')
16
+ await page.fill('input[name="city"]', 'Amsterdam')
17
+ await page.press('input[name="city"]', 'Tab')
18
+ await page.selectOption('select[name="countryCode"]', 'NL')
19
+ await page.click('input[name="telephone"]')
20
+ await page.fill('input[name="telephone"]', '0123456789')
21
+ await page.press('input[name="telephone"]', 'Tab')
22
+ }
package/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './Api/BillingAddress.gql'
2
+ export * from './Api/ShippingAddress.gql'
3
+
4
+ export * from './ShippingAddressForm/ShippingAddressForm'
5
+ export { default as ShippingAddressForm } from './ShippingAddressForm/ShippingAddressForm'
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@graphcommerce/magento-cart-shipping-address",
3
+ "version": "2.103.1",
4
+ "sideEffects": false,
5
+ "prettier": "@graphcommerce/prettier-config-pwa",
6
+ "browserslist": [
7
+ "extends @graphcommerce/browserslist-config-pwa"
8
+ ],
9
+ "eslintConfig": {
10
+ "extends": "@graphcommerce/eslint-config-pwa",
11
+ "parserOptions": {
12
+ "project": "./tsconfig.json"
13
+ }
14
+ },
15
+ "devDependencies": {
16
+ "@graphcommerce/browserslist-config-pwa": "^3.0.1",
17
+ "@graphcommerce/eslint-config-pwa": "^3.0.1",
18
+ "@graphcommerce/prettier-config-pwa": "^3.0.1",
19
+ "@graphcommerce/typescript-config-pwa": "^3.0.1",
20
+ "@playwright/test": "^1.14.1"
21
+ },
22
+ "dependencies": {
23
+ "@apollo/client": "^3.3.21",
24
+ "@graphcommerce/graphql": "^2.103.1",
25
+ "@graphcommerce/image": "^2.104.1",
26
+ "@graphcommerce/magento-cart": "^3.0.1",
27
+ "@graphcommerce/magento-customer": "^3.0.1",
28
+ "@graphcommerce/magento-store": "^3.0.1",
29
+ "@graphcommerce/next-ui": "^3.0.1",
30
+ "@graphcommerce/react-hook-form": "^2.102.1",
31
+ "@graphql-typed-document-node/core": "^3.1.0",
32
+ "@material-ui/core": "^4.12.3",
33
+ "@material-ui/lab": "^4.0.0-alpha.60",
34
+ "clsx": "^1.1.1",
35
+ "framer-motion": "^4.1.17",
36
+ "next": "^11.1.2",
37
+ "react": "^17.0.2",
38
+ "react-dom": "^17.0.2"
39
+ }
40
+ }