@riosst100/pwa-marketplace 2.5.0 → 2.5.2

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,165 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ import { PriceSummaryFragment } from '@magento/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql';
4
+ import { AvailablePaymentMethodsFragment } from '@magento/peregrine/lib/talons/CheckoutPage/PaymentInformation/paymentInformation.gql';
5
+
6
+ export const GET_IS_BILLING_ADDRESS_SAME = gql`
7
+ query getIsBillingAddressSame($cartId: String!) {
8
+ cart(cart_id: $cartId) @client {
9
+ id
10
+ isBillingAddressSame
11
+ }
12
+ }
13
+ `;
14
+
15
+ export const GET_PAYMENT_NONCE = gql`
16
+ query getPaymentNonce($cartId: String!) {
17
+ cart(cart_id: $cartId) @client {
18
+ id
19
+ paymentNonce
20
+ }
21
+ }
22
+ `;
23
+
24
+ export const GET_BILLING_ADDRESS = gql`
25
+ query getBillingAddress($cartId: String!) {
26
+ cart(cart_id: $cartId) {
27
+ id
28
+ billingAddress: billing_address {
29
+ firstName: firstname
30
+ lastName: lastname
31
+ country {
32
+ code
33
+ }
34
+ street
35
+ city
36
+ region {
37
+ code
38
+ label
39
+ region_id
40
+ }
41
+ postcode
42
+ phoneNumber: telephone
43
+ }
44
+ }
45
+ }
46
+ `;
47
+
48
+ export const GET_SHIPPING_ADDRESS = gql`
49
+ query getSelectedShippingAddress($cartId: String!) {
50
+ cart(cart_id: $cartId) {
51
+ id
52
+ shippingAddresses: shipping_addresses {
53
+ firstName: firstname
54
+ lastName: lastname
55
+ country {
56
+ code
57
+ }
58
+ street
59
+ city
60
+ region {
61
+ code
62
+ label
63
+ region_id
64
+ }
65
+ postcode
66
+ phoneNumber: telephone
67
+ }
68
+ }
69
+ }
70
+ `;
71
+
72
+ export const SET_BILLING_ADDRESS = gql`
73
+ mutation setBillingAddress(
74
+ $cartId: String!
75
+ $firstName: String!
76
+ $lastName: String!
77
+ $street1: String!
78
+ $street2: String
79
+ $city: String!
80
+ $region: String!
81
+ $postcode: String!
82
+ $country: String!
83
+ $phoneNumber: String!
84
+ ) {
85
+ setBillingAddressOnCart(
86
+ input: {
87
+ cart_id: $cartId
88
+ billing_address: {
89
+ address: {
90
+ firstname: $firstName
91
+ lastname: $lastName
92
+ street: [$street1, $street2]
93
+ city: $city
94
+ region: $region
95
+ postcode: $postcode
96
+ country_code: $country
97
+ telephone: $phoneNumber
98
+ save_in_address_book: false
99
+ }
100
+ }
101
+ }
102
+ ) {
103
+ cart {
104
+ id
105
+ billing_address {
106
+ firstname
107
+ lastname
108
+ country {
109
+ code
110
+ }
111
+ street
112
+ city
113
+ region {
114
+ code
115
+ label
116
+ region_id
117
+ }
118
+ postcode
119
+ telephone
120
+ }
121
+ ...PriceSummaryFragment
122
+ ...AvailablePaymentMethodsFragment
123
+ }
124
+ }
125
+ }
126
+ ${PriceSummaryFragment}
127
+ ${AvailablePaymentMethodsFragment}
128
+ `;
129
+
130
+ export const SET_CC_DETAILS_ON_CART = gql`
131
+ mutation setSelectedPaymentMethod(
132
+ $cartId: String!
133
+ $paymentNonce: String!
134
+ ) {
135
+ setPaymentMethodOnCart(
136
+ input: {
137
+ cart_id: $cartId
138
+ payment_method: {
139
+ code: "braintree"
140
+ braintree: {
141
+ payment_method_nonce: $paymentNonce
142
+ is_active_payment_token_enabler: false
143
+ }
144
+ }
145
+ }
146
+ ) {
147
+ cart {
148
+ id
149
+ selected_payment_method {
150
+ code
151
+ title
152
+ }
153
+ }
154
+ }
155
+ }
156
+ `;
157
+
158
+ export default {
159
+ getBillingAddressQuery: GET_BILLING_ADDRESS,
160
+ getIsBillingAddressSameQuery: GET_IS_BILLING_ADDRESS_SAME,
161
+ getPaymentNonceQuery: GET_PAYMENT_NONCE,
162
+ getShippingAddressQuery: GET_SHIPPING_ADDRESS,
163
+ setBillingAddressMutation: SET_BILLING_ADDRESS,
164
+ setCreditCardDetailsOnCartMutation: SET_CC_DETAILS_ON_CART
165
+ };