@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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "2.5.0",
4
+ "version": "2.5.2",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -134,7 +134,7 @@ const liveChat = (props) => {
134
134
  />
135
135
  </div>
136
136
  </div>
137
- <style jsx>
137
+ <style jsx="true">
138
138
  {`
139
139
  .chat-container::-webkit-scrollbar {
140
140
  width: 8px;
@@ -31,7 +31,7 @@ const ProductItem = () => {
31
31
  </div>
32
32
  </div>
33
33
  </div>
34
- <style jsx>
34
+ <style jsx="true">
35
35
  {`
36
36
  .line-clamp-2 {
37
37
  display: -webkit-box;
@@ -230,7 +230,7 @@ const RFQModalForm = (props) => {
230
230
  </div>
231
231
  </div>
232
232
  </Modal>
233
- <style jsx>
233
+ <style jsx="true">
234
234
  {`
235
235
  .react-datepicker__input-container>input:focus-visible,
236
236
  .react-datepicker__input-container>input:focus,
@@ -316,7 +316,7 @@ const quoteDetail = () => {
316
316
  </div>
317
317
  </div>
318
318
  </div>
319
- <style jsx>
319
+ <style jsx="true">
320
320
  {`
321
321
  .chat-container::-webkit-scrollbar {
322
322
  width: 8px;
@@ -212,7 +212,7 @@ const RMACreate = () => {
212
212
  </div>
213
213
  </div>
214
214
  </div>
215
- <style jsx>
215
+ <style jsx="true">
216
216
  {`
217
217
  .chat-container::-webkit-scrollbar {
218
218
  width: 8px;
@@ -292,7 +292,7 @@ const RMADetail = () => {
292
292
  </div>
293
293
  </div>
294
294
  </div>
295
- <style jsx>
295
+ <style jsx="true">
296
296
  {`
297
297
  .chat-container::-webkit-scrollbar {
298
298
  width: 8px;
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { shape, string, func } from 'prop-types';
4
+
5
+ import { useSummary } from '@magento/peregrine/lib/talons/CheckoutPage/PaymentInformation/useSummary';
6
+ import { useStyle } from '@magento/venia-ui/lib/classify';
7
+
8
+ import defaultClasses from './summary.module.css';
9
+ import LoadingIndicator from '@magento/venia-ui/lib/components/LoadingIndicator';
10
+ import summaryPayments from '@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/summaryPaymentCollection';
11
+
12
+ const Summary = props => {
13
+ const { classes: propClasses, onEdit } = props;
14
+ const classes = useStyle(defaultClasses, propClasses);
15
+
16
+ const talonProps = useSummary();
17
+
18
+ const { isLoading, selectedPaymentMethod } = talonProps;
19
+
20
+ if (isLoading && !selectedPaymentMethod) {
21
+ return (
22
+ <LoadingIndicator classes={{ root: classes.loading }}>
23
+ <FormattedMessage
24
+ id={'checkoutPage.loadingPaymentInformation'}
25
+ defaultMessage={'Fetching Payment Information'}
26
+ />
27
+ </LoadingIndicator>
28
+ );
29
+ }
30
+
31
+ const hasCustomSummaryComp = Object.keys(summaryPayments).includes(
32
+ selectedPaymentMethod.code
33
+ );
34
+
35
+ if (hasCustomSummaryComp) {
36
+ const SummaryPaymentMethodComponent =
37
+ summaryPayments[selectedPaymentMethod.code];
38
+ return <SummaryPaymentMethodComponent onEdit={onEdit} />;
39
+ } else {
40
+ return (
41
+ <div className={classes.root}>
42
+ <div className={classes.heading_container}>
43
+ <h5 className={classes.heading}>
44
+ <FormattedMessage
45
+ id={'checkoutPage.paymentInformation'}
46
+ defaultMessage={'Payment Information'}
47
+ />
48
+ </h5>
49
+ </div>
50
+ <div className={classes.card_details_container}>
51
+ <span className={classes.payment_details}>
52
+ {selectedPaymentMethod.title}
53
+ </span>
54
+ </div>
55
+ </div>
56
+ );
57
+ }
58
+ };
59
+
60
+ export default Summary;
61
+
62
+ Summary.propTypes = {
63
+ classes: shape({
64
+ root: string,
65
+ heading_container: string,
66
+ heading: string,
67
+ card_details_container: string,
68
+ payment_details: string
69
+ }),
70
+ onEdit: func.isRequired
71
+ };
@@ -0,0 +1,23 @@
1
+ .root {
2
+ composes: gap-xs from global;
3
+ composes: grid from global;
4
+ composes: p-md from global;
5
+ }
6
+
7
+ .heading_container {
8
+ composes: grid from global;
9
+ composes: grid-cols-1 from global;
10
+ composes: grid-flow-col from global;
11
+ }
12
+
13
+ .heading {
14
+ composes: font-semibold from global;
15
+ }
16
+
17
+ .card_details_container {
18
+ composes: gap-2xs from global;
19
+ composes: grid from global;
20
+ }
21
+
22
+ .payment_details {
23
+ }
@@ -0,0 +1,348 @@
1
+ import React, { useMemo, useCallback } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { bool, func, shape, string } from 'prop-types';
4
+ import { useXendit } from '@riosst100/src/talons/Xendit/useXendit';
5
+
6
+ import { isRequired } from '@magento/venia-ui/lib/util/formValidators';
7
+ import Country from '@magento/venia-ui/lib/components/Country';
8
+ import Region from '@magento/venia-ui/lib/components/Region';
9
+ import Postcode from '@magento/venia-ui/lib/components/Postcode';
10
+ import Checkbox from '@magento/venia-ui/lib/components/Checkbox';
11
+ import Field from '@magento/venia-ui/lib/components/Field';
12
+ import TextInput from '@magento/venia-ui/lib/components/TextInput';
13
+ import BrainTreeDropin from './brainTreeDropIn';
14
+ import LoadingIndicator from '@magento/venia-ui/lib/components/LoadingIndicator';
15
+ import { useStyle } from '@magento/venia-ui/lib/classify';
16
+
17
+ import defaultClasses from './xendit.module.css';
18
+ import FormError from '@magento/venia-ui/lib/components/FormError';
19
+ import GoogleReCaptcha from '@magento/venia-ui/lib/components/GoogleReCaptcha';
20
+
21
+ const STEP_DESCRIPTIONS = [
22
+ { defaultMessage: 'Loading Payment', id: 'checkoutPage.step0' },
23
+ {
24
+ defaultMessage: 'Checking Credit Card Information',
25
+ id: 'checkoutPage.step1'
26
+ },
27
+ {
28
+ defaultMessage: 'Checking Credit Card Information',
29
+ id: 'checkoutPage.step2'
30
+ },
31
+ {
32
+ defaultMessage: 'Checking Credit Card Information',
33
+ id: 'checkoutPage.step3'
34
+ },
35
+ {
36
+ defaultMessage: 'Saved Credit Card Information Successfully',
37
+ id: 'checkoutPage.step4'
38
+ }
39
+ ];
40
+
41
+ /**
42
+ * The initial view for the Braintree payment method.
43
+ */
44
+ const Xendit = props => {
45
+ const {
46
+ classes: propClasses,
47
+ onPaymentSuccess: onSuccess,
48
+ onPaymentReady: onReady,
49
+ onPaymentError: onError,
50
+ resetShouldSubmit,
51
+ shouldSubmit
52
+ } = props;
53
+ const { formatMessage } = useIntl();
54
+
55
+ const classes = useStyle(defaultClasses, propClasses);
56
+
57
+ const talonProps = useXendit({
58
+ onSuccess,
59
+ onReady,
60
+ onError,
61
+ shouldSubmit,
62
+ resetShouldSubmit
63
+ });
64
+
65
+ const {
66
+ errors,
67
+ shouldRequestPaymentNonce,
68
+ onPaymentError,
69
+ onPaymentSuccess,
70
+ onPaymentReady,
71
+ isBillingAddressSame,
72
+ isLoading,
73
+ /**
74
+ * `stepNumber` depicts the state of the process flow in credit card
75
+ * payment flow.
76
+ *
77
+ * `0` No call made yet
78
+ * `1` Billing address mutation intiated
79
+ * `2` Braintree nonce requsted
80
+ * `3` Payment information mutation intiated
81
+ * `4` All mutations done
82
+ */
83
+ stepNumber,
84
+ initialValues,
85
+ shippingAddressCountry,
86
+ shouldTeardownDropin,
87
+ resetShouldTeardownDropin,
88
+ recaptchaWidgetProps
89
+ } = talonProps;
90
+
91
+ const creditCardComponentClassName = isLoading
92
+ ? classes.credit_card_root_hidden
93
+ : classes.credit_card_root;
94
+
95
+ const billingAddressFieldsClassName = isBillingAddressSame
96
+ ? classes.billing_address_fields_root_hidden
97
+ : classes.billing_address_fields_root;
98
+
99
+ /**
100
+ * Instead of defining classes={root: classes.FIELD_NAME}
101
+ * we are using useMemo to only do it once (hopefully).
102
+ */
103
+ const fieldClasses = useMemo(() => {
104
+ return [
105
+ 'first_name',
106
+ 'last_name',
107
+ 'country',
108
+ 'street1',
109
+ 'street2',
110
+ 'city',
111
+ 'region',
112
+ 'postal_code',
113
+ 'phone_number'
114
+ ].reduce((acc, fieldName) => {
115
+ acc[fieldName] = { root: classes[fieldName] };
116
+
117
+ return acc;
118
+ }, {});
119
+ }, [classes]);
120
+
121
+ /**
122
+ * These 2 functions are wrappers around the `isRequired` function
123
+ * of `formValidators`. They perform validations only if the
124
+ * billing address is different from shipping address.
125
+ *
126
+ * We write this function in `venia-ui` and not in the `peregrine` talon
127
+ * because it references `isRequired` which is a `venia-ui` function.
128
+ */
129
+ const isFieldRequired = useCallback((value, { isBillingAddressSame }) => {
130
+ if (isBillingAddressSame) {
131
+ /**
132
+ * Informed validator functions return `undefined` if
133
+ * validation is `true`
134
+ */
135
+ return undefined;
136
+ } else {
137
+ return isRequired(value);
138
+ }
139
+ }, []);
140
+
141
+ const stepTitle = STEP_DESCRIPTIONS[stepNumber].defaultMessage
142
+ ? formatMessage({
143
+ id: STEP_DESCRIPTIONS[stepNumber].id,
144
+ defaultMessage: STEP_DESCRIPTIONS[stepNumber].defaultMessage
145
+ })
146
+ : formatMessage({
147
+ id: 'checkoutPage.loadingPayment',
148
+ defaultMessage: 'Loading Payment'
149
+ });
150
+
151
+ const loadingIndicator = isLoading ? (
152
+ <LoadingIndicator>{stepTitle}</LoadingIndicator>
153
+ ) : null;
154
+
155
+ return (
156
+ <div className={classes.root} data-cy="Xendit-root">
157
+ <div className={creditCardComponentClassName}>
158
+ <FormError
159
+ allowErrorMessages
160
+ classes={{ root: classes.formErrorContainer }}
161
+ errors={Array.from(errors.values())}
162
+ />
163
+ <div className={classes.dropin_root}>
164
+ <BrainTreeDropin
165
+ onError={onPaymentError}
166
+ onReady={onPaymentReady}
167
+ onSuccess={onPaymentSuccess}
168
+ shouldRequestPaymentNonce={shouldRequestPaymentNonce}
169
+ shouldTeardownDropin={shouldTeardownDropin}
170
+ resetShouldTeardownDropin={resetShouldTeardownDropin}
171
+ />
172
+ </div>
173
+ <div
174
+ data-cy="Xendit-AddressCheck-root"
175
+ className={classes.address_check}
176
+ >
177
+ <Checkbox
178
+ data-cy="PaymentInformation-billingAddressSame"
179
+ field="isBillingAddressSame"
180
+ label={formatMessage({
181
+ id: 'checkoutPage.billingAddressSame',
182
+ defaultMessage:
183
+ 'Billing address same as shipping address'
184
+ })}
185
+ initialValue={initialValues.isBillingAddressSame}
186
+ />
187
+ </div>
188
+ <div
189
+ data-cy="Xendit-billingAddressFields"
190
+ className={billingAddressFieldsClassName}
191
+ >
192
+ <Field
193
+ id="firstName"
194
+ classes={fieldClasses.first_name}
195
+ label={formatMessage({
196
+ id: 'global.firstName',
197
+ defaultMessage: 'First Name'
198
+ })}
199
+ >
200
+ <TextInput
201
+ data-cy="Xendit-billingAddress-firstname"
202
+ id="firstName"
203
+ field="firstName"
204
+ validate={isFieldRequired}
205
+ initialValue={initialValues.firstName}
206
+ />
207
+ </Field>
208
+ <Field
209
+ id="lastName"
210
+ classes={fieldClasses.last_name}
211
+ label={formatMessage({
212
+ id: 'global.lastName',
213
+ defaultMessage: 'Last Name'
214
+ })}
215
+ >
216
+ <TextInput
217
+ data-cy="Xendit-billingAddress-lastname"
218
+ id="lastName"
219
+ field="lastName"
220
+ validate={isFieldRequired}
221
+ initialValue={initialValues.lastName}
222
+ />
223
+ </Field>
224
+ <Country
225
+ data-cy="Xendit-billingAddress-country"
226
+ classes={fieldClasses.country}
227
+ validate={isFieldRequired}
228
+ initialValue={
229
+ /**
230
+ * If there is no initial value to start with
231
+ * use the country from shipping address.
232
+ */
233
+ initialValues.country || shippingAddressCountry
234
+ }
235
+ />
236
+ <Field
237
+ id="street1"
238
+ classes={fieldClasses.street1}
239
+ label={formatMessage({
240
+ id: 'global.streetAddress',
241
+ defaultMessage: 'Street Address'
242
+ })}
243
+ >
244
+ <TextInput
245
+ data-cy="Xendit-billingAddress-street1"
246
+ id="street1"
247
+ field="street1"
248
+ validate={isFieldRequired}
249
+ initialValue={initialValues.street1}
250
+ />
251
+ </Field>
252
+ <Field
253
+ id="street2"
254
+ classes={fieldClasses.street2}
255
+ label={formatMessage({
256
+ id: 'global.streetAddress2',
257
+ defaultMessage: 'Street Address 2'
258
+ })}
259
+ optional={true}
260
+ >
261
+ <TextInput
262
+ data-cy="Xendit-billingAddress-street2"
263
+ id="street2"
264
+ field="street2"
265
+ initialValue={initialValues.street2}
266
+ />
267
+ </Field>
268
+ <Field
269
+ id="city"
270
+ classes={fieldClasses.city}
271
+ label={formatMessage({
272
+ id: 'global.city',
273
+ defaultMessage: 'City'
274
+ })}
275
+ >
276
+ <TextInput
277
+ data-cy="Xendit-billingAddress-city"
278
+ id="city"
279
+ field="city"
280
+ validate={isFieldRequired}
281
+ initialValue={initialValues.city}
282
+ />
283
+ </Field>
284
+ <Region
285
+ data-cy="Xendit-billingAddress-region"
286
+ classes={fieldClasses.region}
287
+ initialValue={initialValues.region}
288
+ validate={isFieldRequired}
289
+ fieldInput={'region[label]'}
290
+ fieldSelect={'region[region_id]'}
291
+ optionValueKey={'id'}
292
+ />
293
+ <Postcode
294
+ data-cy="Xendit-billingAddress-postcode"
295
+ classes={fieldClasses.postal_code}
296
+ validate={isFieldRequired}
297
+ initialValue={initialValues.postcode}
298
+ />
299
+ <Field
300
+ id="phoneNumber"
301
+ classes={fieldClasses.phone_number}
302
+ label={formatMessage({
303
+ id: 'global.phoneNumber',
304
+ defaultMessage: 'Phone Number'
305
+ })}
306
+ >
307
+ <TextInput
308
+ data-cy="Xendit-billingAddress-phoneNumber"
309
+ id="phoneNumber"
310
+ field="phoneNumber"
311
+ validate={isFieldRequired}
312
+ initialValue={initialValues.phoneNumber}
313
+ />
314
+ </Field>
315
+ </div>
316
+ <GoogleReCaptcha {...recaptchaWidgetProps} />
317
+ </div>
318
+ {loadingIndicator}
319
+ </div>
320
+ );
321
+ };
322
+
323
+ export default Xendit;
324
+
325
+ Xendit.propTypes = {
326
+ classes: shape({
327
+ root: string,
328
+ dropin_root: string,
329
+ billing_address_fields_root: string,
330
+ first_name: string,
331
+ last_name: string,
332
+ city: string,
333
+ region: string,
334
+ postal_code: string,
335
+ phone_number: string,
336
+ country: string,
337
+ street1: string,
338
+ street2: string,
339
+ address_check: string,
340
+ credit_card_root: string,
341
+ credit_card_root_hidden: string
342
+ }),
343
+ shouldSubmit: bool.isRequired,
344
+ onPaymentSuccess: func,
345
+ onPaymentReady: func,
346
+ onPaymentError: func,
347
+ resetShouldSubmit: func.isRequired
348
+ };
@@ -0,0 +1,58 @@
1
+ .root {
2
+ }
3
+
4
+ .credit_card_root {
5
+ composes: visible from global;
6
+ composes: opacity-100 from global;
7
+ transition-delay: 64ms;
8
+ transition-duration: 384ms;
9
+ transition-property: opacity, visbility;
10
+ transition-timing-function: var(--venia-global-anim-standard);
11
+ }
12
+
13
+ .credit_card_root_hidden {
14
+ composes: h-0 from global;
15
+ composes: invisible from global;
16
+ composes: opacity-0 from global;
17
+ composes: overflow-hidden from global;
18
+ }
19
+
20
+ .dropin_root {
21
+ }
22
+
23
+ .billing_address_fields_root {
24
+ composes: gap-x-xs from global;
25
+ composes: gap-y-sm from global;
26
+ composes: grid from global;
27
+ composes: px-0 from global;
28
+ composes: py-xs from global;
29
+ }
30
+
31
+ .billing_address_fields_root_hidden {
32
+ composes: h-0 from global;
33
+ composes: invisible from global;
34
+ composes: opacity-0 from global;
35
+ composes: overflow-hidden from global;
36
+ }
37
+
38
+ .formErrorContainer {
39
+ composes: pt-sm from global;
40
+ }
41
+
42
+ .first_name,
43
+ .last_name {
44
+ composes: col-end-span2 from global;
45
+
46
+ composes: lg_col-end-span1 from global;
47
+ }
48
+
49
+ .country,
50
+ .street1,
51
+ .street2,
52
+ .address_check,
53
+ .city,
54
+ .region,
55
+ .postal_code,
56
+ .phone_number {
57
+ composes: col-end-span2 from global;
58
+ }
package/src/intercept.js CHANGED
@@ -220,4 +220,18 @@ module.exports = targets => {
220
220
  routesArray.push(...routes);
221
221
  return routesArray;
222
222
  });
223
+
224
+ targets.of('@magento/venia-ui').checkoutPagePaymentTypes.tap(checkoutPagePaymentTypes =>
225
+ checkoutPagePaymentTypes.add({
226
+ paymentCode: 'xendit',
227
+ importPath: '@riosst100/pwa-marketplace/src/components/Xendit/xendit.js'
228
+ })
229
+ );
230
+
231
+ // targets.of('@magento/venia-ui').summaryPagePaymentTypes.tap(summaryPagePaymentTypes =>
232
+ // summaryPagePaymentTypes.add({
233
+ // paymentCode: 'xendit',
234
+ // importPath: '@riosst100/pwa-marketplace/src/components/Xendit/summary.js'
235
+ // })
236
+ // );
223
237
  };
@@ -10,8 +10,6 @@ export const createSellerCart = payload =>
10
10
  const { cart } = getState();
11
11
 
12
12
  // Request a new cart.
13
- dispatch(actions.getSellerCart.request());
14
-
15
13
  try {
16
14
  // errors can come from graphql and are not thrown
17
15
  const { data, errors } = await initCheckoutSplitCart({
@@ -42,12 +40,9 @@ export const createSellerCart = payload =>
42
40
  // write to storage in the background
43
41
  saveSellerCartId(data.initCheckoutSplitCart.quote_id);
44
42
  }
45
-
46
- dispatch(actions.getSellerCart.receive(receivePayload));
47
43
  } catch (error) {
48
44
  // If we are unable to create a cart, the cart can't function, so
49
45
  // we forcibly throw so the upstream actions won't retry.
50
- dispatch(actions.getSellerCart.receive(error));
51
46
  throw new Error('Unable to create seller cart');
52
47
  }
53
48
  };
@@ -16,7 +16,7 @@ const OrderSummary = props => {
16
16
  />
17
17
  </h2>
18
18
  <PriceSummary isUpdating={props.isUpdating} />
19
- <style jsx>
19
+ <style jsx="true">
20
20
  {`
21
21
  li[class*="priceSummary-lineItems"] span:first-child {
22
22
  margin-top: 0;
@@ -37,6 +37,12 @@ const PaymentMethods = props => {
37
37
  return null;
38
38
  }
39
39
 
40
+ console.log('payments')
41
+ console.log(payments)
42
+
43
+ console.log('availablePaymentMethods')
44
+ console.log(availablePaymentMethods)
45
+
40
46
  const radios = availablePaymentMethods
41
47
  .map(({ code, title }) => {
42
48
  // If we don't have an implementation for a method type, ignore it.
@@ -74,6 +80,9 @@ const PaymentMethods = props => {
74
80
  })
75
81
  .filter(paymentMethod => !!paymentMethod);
76
82
 
83
+ console.log('radios != [] harusny')
84
+ console.log(radios)
85
+
77
86
  const noPaymentMethodMessage = !radios.length ? (
78
87
  <div className={classes.payment_errors}>
79
88
  <span>