@riosst100/pwa-marketplace 2.6.3 → 2.6.5

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.6.3",
4
+ "version": "2.6.5",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -63,8 +63,10 @@ const FilterTopItem = props => {
63
63
 
64
64
  let newfilterSearchArr = search ? search.split('&') : [];
65
65
  newfilterSearchArr = newfilterSearchArr.filter(function(data) {
66
- return !data.includes('card_game%5Bfilter%5D');
66
+ return !data.includes(group + '%5Bfilter%5D');
67
67
  });
68
+
69
+ // alert(group)
68
70
 
69
71
  let filterSearch = newfilterSearchArr.join('&')
70
72
 
@@ -0,0 +1 @@
1
+ export {default} from './paypalExpress';
@@ -0,0 +1,25 @@
1
+ .root {
2
+ padding-top: 1.125rem;
3
+ }
4
+
5
+ .title {
6
+ font-weight: var(--venia-global-fontWeight-semibold);
7
+ }
8
+
9
+ .mailingAddressTitle {
10
+ font-weight: var(--venia-global-fontWeight-semibold);
11
+ padding-top: 1rem;
12
+ }
13
+
14
+ .note {
15
+ padding: 1rem 0;
16
+ }
17
+
18
+ .formatAddress {
19
+ padding: 0.5rem 0;
20
+ }
21
+
22
+ .addressLine {
23
+ display: block;
24
+ padding-bottom: 0.5rem;
25
+ }
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import {mergeClasses} from '@magento/venia-ui/lib/classify';
3
+ import {shape, string, bool, func} from 'prop-types';
4
+ import BillingAddress from '@magento/venia-ui/lib/components/CheckoutPage/BillingAddress';
5
+
6
+ import {usePaypalExpress} from '../../talons/PaymentMethod/PaypalExpress/usePaypalExpress';
7
+ import defaultClasses from './paypalExpress.css';
8
+ import {FormattedMessage} from 'react-intl';
9
+
10
+ /**
11
+ *
12
+ * @param props
13
+ * @returns {JSX.Element}
14
+ * @constructor
15
+ */
16
+ const PaypalExpress = props => {
17
+ const classes = mergeClasses(defaultClasses, props.classes);
18
+
19
+ const {
20
+ resetShouldSubmit,
21
+ onPaymentSuccess,
22
+ onPaymentError,
23
+ currentSelectedPaymentMethod
24
+ } = props;
25
+
26
+ const {
27
+ onBillingAddressChangedError,
28
+ onBillingAddressChangedSuccess
29
+ } = usePaypalExpress({
30
+ resetShouldSubmit,
31
+ onPaymentSuccess,
32
+ onPaymentError,
33
+ currentSelectedPaymentMethod
34
+ });
35
+
36
+ return (
37
+ <div className={classes.root}>
38
+ <p className={classes.note}>
39
+ <FormattedMessage
40
+ id={'multiSafepayPayment.note'}
41
+ defaultMessage={'Note: You will be redirected to the payment page.'}
42
+ />
43
+ </p>
44
+ <BillingAddress
45
+ shouldSubmit={props.shouldSubmit}
46
+ resetShouldSubmit={resetShouldSubmit}
47
+ onBillingAddressChangedError={onBillingAddressChangedError}
48
+ onBillingAddressChangedSuccess={onBillingAddressChangedSuccess}
49
+ />
50
+ </div>
51
+ );
52
+ };
53
+
54
+ PaypalExpress.propTypes = {
55
+ classes: shape({root: string}),
56
+ shouldSubmit: bool.isRequired,
57
+ onPaymentSuccess: func,
58
+ onPaymentError: func,
59
+ resetShouldSubmit: func.isRequired
60
+ };
61
+
62
+ export default PaypalExpress;
@@ -0,0 +1 @@
1
+ export {default} from '../PaypalExpress/paypalExpress';
package/src/intercept.js CHANGED
@@ -221,6 +221,22 @@ module.exports = targets => {
221
221
  return routesArray;
222
222
  });
223
223
 
224
+ const paymentMethods = [
225
+ 'paypal_express'
226
+ ];
227
+
228
+ const veniaTargets = targets.of('@magento/venia-ui');
229
+ const gatewaysPath = '@riosst100/pwa-marketplace/src/components/PaymentMethod/';
230
+
231
+ paymentMethods.map(method =>
232
+ veniaTargets.checkoutPagePaymentTypes.tap(checkoutPagePaymentTypes =>
233
+ checkoutPagePaymentTypes.add({
234
+ paymentCode: method,
235
+ importPath: gatewaysPath + method
236
+ })
237
+ )
238
+ );
239
+
224
240
  // targets.of('@magento/venia-ui').checkoutPagePaymentTypes.tap(checkoutPagePaymentTypes =>
225
241
  // checkoutPagePaymentTypes.add({
226
242
  // paymentCode: 'xendit',
@@ -37,6 +37,8 @@ const PaymentMethods = props => {
37
37
  return null;
38
38
  }
39
39
 
40
+ console.log('payments', payments)
41
+
40
42
  const radios = availablePaymentMethods
41
43
  .map(({ code, title }) => {
42
44
  // If we don't have an implementation for a method type, ignore it.
@@ -0,0 +1,29 @@
1
+ import {gql} from '@apollo/client';
2
+
3
+ export const SelectedPaymentMethodsFragment = gql`
4
+ fragment SelectedPaymentMethodsFragment on Cart {
5
+ id
6
+ selected_payment_method {
7
+ code
8
+ title
9
+ }
10
+ }
11
+ `;
12
+
13
+
14
+ export const SET_PAYMENT_METHOD_ON_CART = gql`
15
+ mutation setPaymentMethodOnCart($cartId: String!, $selectedMethod: String!) {
16
+ setPaymentMethodOnCart(
17
+ input: { cart_id: $cartId, payment_method: { code: $selectedMethod } }
18
+ ) @connection(key: "setPaymentMethodOnCart") {
19
+ cart {
20
+ ...SelectedPaymentMethodsFragment
21
+ }
22
+ }
23
+ }
24
+ ${SelectedPaymentMethodsFragment}
25
+ `;
26
+
27
+ export default {
28
+ setPaymentMethodOnCartMutation: SET_PAYMENT_METHOD_ON_CART
29
+ };
@@ -0,0 +1,69 @@
1
+ import {useCallback, useEffect} from 'react';
2
+ import {useMutation} from '@apollo/client';
3
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
4
+ import {useCartContext} from '@magento/peregrine/lib/context/cart';
5
+
6
+ import DEFAULT_OPERATIONS from './paypalExpress.gql';
7
+
8
+ export const usePaypalExpress = props => {
9
+ const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
10
+
11
+ const {
12
+ setPaymentMethodOnCartMutation
13
+ } = operations;
14
+
15
+ const [{cartId}] = useCartContext();
16
+ const {currentSelectedPaymentMethod: selectedMethod} = props;
17
+
18
+ const {resetShouldSubmit, onPaymentSuccess, onPaymentError} = props;
19
+
20
+ const [
21
+ updatePaymentMethod,
22
+ {
23
+ error: paymentMethodMutationError,
24
+ called: paymentMethodMutationCalled,
25
+ loading: paymentMethodMutationLoading
26
+ }
27
+ ] = useMutation(setPaymentMethodOnCartMutation);
28
+
29
+ /**
30
+ * This function will be called if cant not set address.
31
+ */
32
+ const onBillingAddressChangedError = useCallback(() => {
33
+ resetShouldSubmit();
34
+ }, [resetShouldSubmit]);
35
+
36
+ /**
37
+ * This function will be called if address was successfully set.
38
+ */
39
+ const onBillingAddressChangedSuccess = useCallback(() => {
40
+ updatePaymentMethod({
41
+ variables: {cartId, selectedMethod}
42
+ });
43
+ }, [updatePaymentMethod, cartId, selectedMethod]);
44
+
45
+ useEffect(() => {
46
+ const paymentMethodMutationCompleted =
47
+ paymentMethodMutationCalled && !paymentMethodMutationLoading;
48
+
49
+ if (paymentMethodMutationCompleted && !paymentMethodMutationError) {
50
+ onPaymentSuccess();
51
+ }
52
+
53
+ if (paymentMethodMutationCompleted && paymentMethodMutationError) {
54
+ onPaymentError();
55
+ }
56
+ }, [
57
+ paymentMethodMutationError,
58
+ paymentMethodMutationLoading,
59
+ paymentMethodMutationCalled,
60
+ onPaymentSuccess,
61
+ onPaymentError,
62
+ resetShouldSubmit
63
+ ]);
64
+
65
+ return {
66
+ onBillingAddressChangedError,
67
+ onBillingAddressChangedSuccess
68
+ };
69
+ };