ordering-ui-external 2.5.0 → 2.5.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.
- package/_bundles/{0.ordering-ui.5657c6a53b3791887fd7.js → 0.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/{1.ordering-ui.5657c6a53b3791887fd7.js → 1.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/{2.ordering-ui.5657c6a53b3791887fd7.js → 2.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/{4.ordering-ui.5657c6a53b3791887fd7.js → 4.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/{5.ordering-ui.5657c6a53b3791887fd7.js → 5.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/{6.ordering-ui.5657c6a53b3791887fd7.js → 6.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/{7.ordering-ui.5657c6a53b3791887fd7.js → 7.ordering-ui.5488030edb520175432d.js} +2 -2
- package/_bundles/{8.ordering-ui.5657c6a53b3791887fd7.js → 8.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/{9.ordering-ui.5657c6a53b3791887fd7.js → 9.ordering-ui.5488030edb520175432d.js} +1 -1
- package/_bundles/ordering-ui.5488030edb520175432d.js +2 -0
- package/_modules/components/StripeMethodForm/index.js +26 -11
- package/_modules/themes/five/src/components/CitiesControl/index.js +1 -1
- package/_modules/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +1 -1
- package/_modules/themes/five/src/components/MultiCartsPaymethodsAndWallets/index.js +36 -5
- package/_modules/themes/five/src/components/MultiCheckout/index.js +30 -3
- package/_modules/themes/five/src/components/OrderDetails/OrderEta.js +2 -4
- package/_modules/themes/five/src/components/PaymentOptions/index.js +8 -5
- package/_modules/themes/five/src/components/StripeElementsForm/index.js +3 -1
- package/package.json +1 -1
- package/src/components/StripeMethodForm/index.js +22 -10
- package/src/themes/five/src/components/CitiesControl/index.js +1 -1
- package/src/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +1 -1
- package/src/themes/five/src/components/MultiCartsPaymethodsAndWallets/index.js +83 -51
- package/src/themes/five/src/components/MultiCheckout/index.js +16 -0
- package/src/themes/five/src/components/OrderDetails/OrderEta.js +4 -2
- package/src/themes/five/src/components/PaymentOptions/index.js +7 -4
- package/src/themes/five/src/components/StripeElementsForm/index.js +3 -1
- package/_bundles/ordering-ui.5657c6a53b3791887fd7.js +0 -2
- /package/_bundles/{7.ordering-ui.5657c6a53b3791887fd7.js.LICENSE.txt → 7.ordering-ui.5488030edb520175432d.js.LICENSE.txt} +0 -0
- /package/_bundles/{ordering-ui.5657c6a53b3791887fd7.js.LICENSE.txt → ordering-ui.5488030edb520175432d.js.LICENSE.txt} +0 -0
|
@@ -31,11 +31,15 @@ var StripeMethodFormUI = function StripeMethodFormUI(props) {
|
|
|
31
31
|
var cart = props.cart,
|
|
32
32
|
handleSource = props.handleSource,
|
|
33
33
|
handleCancel = props.handleCancel,
|
|
34
|
-
paymethod = props.paymethod
|
|
34
|
+
paymethod = props.paymethod,
|
|
35
|
+
cartGroup = props.cartGroup;
|
|
35
36
|
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
36
37
|
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
37
38
|
t = _useLanguage2[1];
|
|
38
39
|
var stripe = (0, _reactStripeJs.useStripe)();
|
|
40
|
+
var _useConfig = (0, _orderingComponentsExternal.useConfig)(),
|
|
41
|
+
_useConfig2 = _slicedToArray(_useConfig, 1),
|
|
42
|
+
configs = _useConfig2[0].configs;
|
|
39
43
|
var _useState = (0, _react.useState)(null),
|
|
40
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
41
45
|
paymentRequest = _useState2[0],
|
|
@@ -44,15 +48,24 @@ var StripeMethodFormUI = function StripeMethodFormUI(props) {
|
|
|
44
48
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
49
|
methodUnavailable = _useState4[0],
|
|
46
50
|
setMethodUnavailable = _useState4[1];
|
|
51
|
+
var googlePayMethods = ['google_pay', 'global_google_pay'];
|
|
47
52
|
(0, _react.useEffect)(function () {
|
|
48
53
|
if (stripe) {
|
|
49
|
-
var _cart$
|
|
54
|
+
var _configs$stripe_curre, _configs$stripe_curre2, _configs$stripe_curre3, _cart$business2;
|
|
55
|
+
var cartNames = '';
|
|
56
|
+
if (cartGroup) {
|
|
57
|
+
// eslint-disable-next-line no-unused-expressions
|
|
58
|
+
cartGroup === null || cartGroup === void 0 ? void 0 : cartGroup.carts.map(function (cart, i) {
|
|
59
|
+
var _cart$business, _cartNames, _cartNames$carts;
|
|
60
|
+
return cartNames = "".concat(cart === null || cart === void 0 ? void 0 : (_cart$business = cart.business) === null || _cart$business === void 0 ? void 0 : _cart$business.name, " ").concat(i !== ((_cartNames = cartNames) === null || _cartNames === void 0 ? void 0 : (_cartNames$carts = _cartNames.carts) === null || _cartNames$carts === void 0 ? void 0 : _cartNames$carts.length) && ', ');
|
|
61
|
+
});
|
|
62
|
+
}
|
|
50
63
|
var pr = stripe.paymentRequest({
|
|
51
64
|
country: 'US',
|
|
52
|
-
currency: 'usd',
|
|
65
|
+
currency: (configs === null || configs === void 0 ? void 0 : (_configs$stripe_curre = configs.stripe_currency) === null || _configs$stripe_curre === void 0 ? void 0 : (_configs$stripe_curre2 = _configs$stripe_curre.value) === null || _configs$stripe_curre2 === void 0 ? void 0 : (_configs$stripe_curre3 = _configs$stripe_curre2.toLowerCase) === null || _configs$stripe_curre3 === void 0 ? void 0 : _configs$stripe_curre3.call(_configs$stripe_curre2)) || 'usd',
|
|
53
66
|
total: {
|
|
54
|
-
label: cart === null || cart === void 0 ? void 0 : (_cart$
|
|
55
|
-
amount: Math.floor(((cart === null || cart === void 0 ? void 0 : cart.balance) || (cart === null || cart === void 0 ? void 0 : cart.total)) * 100)
|
|
67
|
+
label: cartNames || (cart === null || cart === void 0 ? void 0 : (_cart$business2 = cart.business) === null || _cart$business2 === void 0 ? void 0 : _cart$business2.name),
|
|
68
|
+
amount: Math.floor(((cartGroup === null || cartGroup === void 0 ? void 0 : cartGroup.balance) || (cartGroup === null || cartGroup === void 0 ? void 0 : cartGroup.total) || (cart === null || cart === void 0 ? void 0 : cart.balance) || (cart === null || cart === void 0 ? void 0 : cart.total)) * 100)
|
|
56
69
|
},
|
|
57
70
|
requestPayerName: true,
|
|
58
71
|
requestPayerEmail: true
|
|
@@ -67,12 +80,11 @@ var StripeMethodFormUI = function StripeMethodFormUI(props) {
|
|
|
67
80
|
pr.on('paymentmethod', /*#__PURE__*/function () {
|
|
68
81
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
69
82
|
var _e$paymentMethod, _e$paymentMethod2;
|
|
83
|
+
var data;
|
|
70
84
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
71
85
|
while (1) switch (_context.prev = _context.next) {
|
|
72
86
|
case 0:
|
|
73
|
-
e.
|
|
74
|
-
handleCancel();
|
|
75
|
-
handleSource(_objectSpread(_objectSpread({}, e === null || e === void 0 ? void 0 : (_e$paymentMethod = e.paymentMethod) === null || _e$paymentMethod === void 0 ? void 0 : _e$paymentMethod.card), {}, {
|
|
87
|
+
data = _objectSpread(_objectSpread({}, e === null || e === void 0 ? void 0 : (_e$paymentMethod = e.paymentMethod) === null || _e$paymentMethod === void 0 ? void 0 : _e$paymentMethod.card), {}, {
|
|
76
88
|
id: e.paymentMethod.id,
|
|
77
89
|
type: e.paymentMethod.type,
|
|
78
90
|
source_id: e === null || e === void 0 ? void 0 : (_e$paymentMethod2 = e.paymentMethod) === null || _e$paymentMethod2 === void 0 ? void 0 : _e$paymentMethod2.id,
|
|
@@ -80,8 +92,11 @@ var StripeMethodFormUI = function StripeMethodFormUI(props) {
|
|
|
80
92
|
brand: e.paymentMethod.card.brand,
|
|
81
93
|
last4: e.paymentMethod.card.last4
|
|
82
94
|
}
|
|
83
|
-
})
|
|
84
|
-
|
|
95
|
+
});
|
|
96
|
+
e.complete('success');
|
|
97
|
+
handleCancel();
|
|
98
|
+
handleSource(cartGroup ? JSON.stringify(data) : data);
|
|
99
|
+
case 4:
|
|
85
100
|
case "end":
|
|
86
101
|
return _context.stop();
|
|
87
102
|
}
|
|
@@ -93,7 +108,7 @@ var StripeMethodFormUI = function StripeMethodFormUI(props) {
|
|
|
93
108
|
}());
|
|
94
109
|
}
|
|
95
110
|
}, [stripe]);
|
|
96
|
-
return /*#__PURE__*/_react.default.createElement(_styles.Container, null, methodUnavailable ? /*#__PURE__*/_react.default.createElement("h2", null, paymethod
|
|
111
|
+
return /*#__PURE__*/_react.default.createElement(_styles.Container, null, methodUnavailable ? /*#__PURE__*/_react.default.createElement("h2", null, googlePayMethods.includes(paymethod) ? t('GOOGLE_PAY_UNAVAILABLE', 'Google pay unavailable') : t('APPLE_PAY_UNAVAILABLE', 'Apple pay unavailable')) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, paymentRequest ? /*#__PURE__*/_react.default.createElement(_reactStripeJs.PaymentRequestButtonElement, {
|
|
97
112
|
options: {
|
|
98
113
|
paymentRequest: paymentRequest
|
|
99
114
|
}
|
|
@@ -49,7 +49,7 @@ var CitiesControl = function CitiesControl(props) {
|
|
|
49
49
|
marginBottom: '10px'
|
|
50
50
|
}
|
|
51
51
|
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, cities === null || cities === void 0 ? void 0 : cities.map(function (city) {
|
|
52
|
-
return /*#__PURE__*/_react.default.createElement(_styles.CityItem, {
|
|
52
|
+
return (city === null || city === void 0 ? void 0 : city.enabled) && /*#__PURE__*/_react.default.createElement(_styles.CityItem, {
|
|
53
53
|
key: city === null || city === void 0 ? void 0 : city.id,
|
|
54
54
|
onClick: function onClick() {
|
|
55
55
|
return setCityState((city === null || city === void 0 ? void 0 : city.id) === cityState ? null : city === null || city === void 0 ? void 0 : city.id);
|
|
@@ -154,7 +154,7 @@ var OriginalHomeHero = function OriginalHomeHero(props) {
|
|
|
154
154
|
isFullScreen: isFullScreen
|
|
155
155
|
}, /*#__PURE__*/_react.default.createElement(_styles.ContentWrapper, null, windowSize.width < 576 && !isChew && /*#__PURE__*/_react.default.createElement(_styles.LogoWrapper, null, /*#__PURE__*/_react.default.createElement("img", {
|
|
156
156
|
alt: "Logotype",
|
|
157
|
-
src:
|
|
157
|
+
src: theme === null || theme === void 0 ? void 0 : (_theme$images3 = theme.images) === null || _theme$images3 === void 0 ? void 0 : (_theme$images3$logos = _theme$images3.logos) === null || _theme$images3$logos === void 0 ? void 0 : _theme$images3$logos.logotypeInvert,
|
|
158
158
|
loading: "lazy"
|
|
159
159
|
})), /*#__PURE__*/_react.default.createElement(_styles.HeroContent, null, /*#__PURE__*/_react.default.createElement(_styles.Title, null, t('TITLE_HOME', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag = theme.defaultLanguages) === null || _theme$defaultLanguag === void 0 ? void 0 : _theme$defaultLanguag.TITLE_HOME) || 'All We need is Food.')), /*#__PURE__*/_react.default.createElement(_styles.Slogan, null, t('SUBTITLE_HOME', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag2 = theme.defaultLanguages) === null || _theme$defaultLanguag2 === void 0 ? void 0 : _theme$defaultLanguag2.SUBTITLE_HOME) || 'Let\'s start to order food now')), /*#__PURE__*/_react.default.createElement(_styles.WrapInput, {
|
|
160
160
|
onClick: handleAddressInput,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.MultiCartsPaymethodsAndWallets = void 0;
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _orderingComponentsExternal = require("ordering-components-external");
|
|
10
10
|
var _styledComponents = require("styled-components");
|
|
11
11
|
var _reactLoadingSkeleton = _interopRequireDefault(require("react-loading-skeleton"));
|
|
@@ -19,7 +19,11 @@ var _Checkbox = require("../../../../../styles/Checkbox");
|
|
|
19
19
|
var _PaymentOptionStripe = require("../PaymentOptionStripe");
|
|
20
20
|
var _utils = require("../../../../../utils");
|
|
21
21
|
var _styles = require("./styles");
|
|
22
|
+
var _StripeElementsForm = require("../StripeElementsForm");
|
|
23
|
+
var _Modal = _interopRequireDefault(require("../Modal"));
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
27
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
28
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
29
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -69,7 +73,7 @@ var CreditCard2 = function CreditCard2() {
|
|
|
69
73
|
}));
|
|
70
74
|
};
|
|
71
75
|
var MultiCartsPaymethodsAndWalletsUI = function MultiCartsPaymethodsAndWalletsUI(props) {
|
|
72
|
-
var _configs$wallet_cash_, _configs$wallet_credi, _paymethodSelected$pa, _paymethodSelected$pa2, _paymethodSelected$pa3, _paymethodSelected$pa4, _paymethodSelected$pa5, _paymethodSelected$pa6, _paymethodSelected$pa7, _paymethodSelected$pa8, _paymethodSelected$pa9, _paymethodSelected$pa10, _walletsState$result;
|
|
76
|
+
var _configs$wallet_cash_, _configs$wallet_credi, _paymethodSelected$pa, _paymethodSelected$pa2, _paymethodSelected$pa3, _paymethodSelected$pa4, _paymethodSelected$pa5, _paymethodSelected$pa6, _paymethodSelected$pa7, _paymethodSelected$pa8, _paymethodSelected$pa9, _paymethodSelected$pa10, _walletsState$result, _paymethodSelected$pa11, _paymethodSelected$da, _paymethodSelected$da2, _paymethodSelected$pa12, _paymethodSelected$pa13, _paymethodSelected$da3, _paymethodSelected$da4;
|
|
73
77
|
var businessIds = props.businessIds,
|
|
74
78
|
balance = props.balance,
|
|
75
79
|
paymethodsAndWallets = props.paymethodsAndWallets,
|
|
@@ -80,7 +84,9 @@ var MultiCartsPaymethodsAndWalletsUI = function MultiCartsPaymethodsAndWalletsUI
|
|
|
80
84
|
handlePaymethodDataChange = props.handlePaymethodDataChange,
|
|
81
85
|
setCardList = props.setCardList,
|
|
82
86
|
walletsPaymethod = props.walletsPaymethod,
|
|
83
|
-
isCustomerMode = props.isCustomerMode
|
|
87
|
+
isCustomerMode = props.isCustomerMode,
|
|
88
|
+
handlePlaceOrder = props.handlePlaceOrder,
|
|
89
|
+
cartGroup = props.cartGroup;
|
|
84
90
|
var theme = (0, _styledComponents.useTheme)();
|
|
85
91
|
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
86
92
|
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
@@ -91,8 +97,14 @@ var MultiCartsPaymethodsAndWalletsUI = function MultiCartsPaymethodsAndWalletsUI
|
|
|
91
97
|
var _useUtils = (0, _orderingComponentsExternal.useUtils)(),
|
|
92
98
|
_useUtils2 = _slicedToArray(_useUtils, 1),
|
|
93
99
|
parsePrice = _useUtils2[0].parsePrice;
|
|
100
|
+
var _useState = (0, _react.useState)(null),
|
|
101
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
102
|
+
openPaymethod = _useState2[0],
|
|
103
|
+
setOpenPaymethod = _useState2[1];
|
|
94
104
|
var isWalletCashEnabled = (configs === null || configs === void 0 ? void 0 : (_configs$wallet_cash_ = configs.wallet_cash_enabled) === null || _configs$wallet_cash_ === void 0 ? void 0 : _configs$wallet_cash_.value) === '1';
|
|
95
105
|
var isWalletPointsEnabled = (configs === null || configs === void 0 ? void 0 : (_configs$wallet_credi = configs.wallet_credit_point_enabled) === null || _configs$wallet_credi === void 0 ? void 0 : _configs$wallet_credi.value) === '1';
|
|
106
|
+
var methodsPay = ['global_google_pay', 'global_apple_pay'];
|
|
107
|
+
var stripeDirectMethods = ['stripe_direct'].concat(methodsPay);
|
|
96
108
|
var walletName = {
|
|
97
109
|
cash: {
|
|
98
110
|
name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
|
|
@@ -121,12 +133,13 @@ var MultiCartsPaymethodsAndWalletsUI = function MultiCartsPaymethodsAndWalletsUI
|
|
|
121
133
|
}, (!isCustomerMode || isCustomerMode && (paymethod.gateway === 'card_delivery' || paymethod.gateway === 'cash')) && /*#__PURE__*/_react.default.createElement(_styles.PayCard, {
|
|
122
134
|
isActive: (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.id) === paymethod.id,
|
|
123
135
|
onClick: function onClick() {
|
|
124
|
-
|
|
136
|
+
handleSelectPaymethod(_objectSpread(_objectSpread({}, paymethod), {}, {
|
|
125
137
|
paymethod: {
|
|
126
138
|
gateway: paymethod.gateway
|
|
127
139
|
},
|
|
128
140
|
paymethod_id: paymethod === null || paymethod === void 0 ? void 0 : paymethod.id
|
|
129
141
|
}));
|
|
142
|
+
setOpenPaymethod(paymethod);
|
|
130
143
|
}
|
|
131
144
|
}, /*#__PURE__*/_react.default.createElement("div", null, getPayIcon(paymethod.id)), /*#__PURE__*/_react.default.createElement("p", null, t(paymethod === null || paymethod === void 0 ? void 0 : paymethod.gateway.toUpperCase(), paymethod === null || paymethod === void 0 ? void 0 : paymethod.name))));
|
|
132
145
|
})), (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$pa = paymethodSelected.paymethod) === null || _paymethodSelected$pa === void 0 ? void 0 : _paymethodSelected$pa.gateway) === 'stripe' && /*#__PURE__*/_react.default.createElement(_PaymentOptionStripe.PaymentOptionStripe, {
|
|
@@ -193,7 +206,25 @@ var MultiCartsPaymethodsAndWalletsUI = function MultiCartsPaymethodsAndWalletsUI
|
|
|
193
206
|
}, "".concat(wallet === null || wallet === void 0 ? void 0 : wallet.balance, " ").concat(t('POINTS', 'Points'))), " ", (wallet === null || wallet === void 0 ? void 0 : wallet.balance) > 0 && "= ".concat(parsePrice((wallet === null || wallet === void 0 ? void 0 : wallet.balance) / (wallet === null || wallet === void 0 ? void 0 : wallet.redemption_rate), {
|
|
194
207
|
isTruncable: true
|
|
195
208
|
})))));
|
|
196
|
-
})))
|
|
209
|
+
}))), /*#__PURE__*/_react.default.createElement(_Modal.default, {
|
|
210
|
+
title: t('ADD_CARD', 'Add card'),
|
|
211
|
+
open: (stripeDirectMethods === null || stripeDirectMethods === void 0 ? void 0 : stripeDirectMethods.includes(openPaymethod === null || openPaymethod === void 0 ? void 0 : openPaymethod.gateway)) && !(paymethodSelected !== null && paymethodSelected !== void 0 && (_paymethodSelected$pa11 = paymethodSelected.paymethod_data) !== null && _paymethodSelected$pa11 !== void 0 && _paymethodSelected$pa11.id),
|
|
212
|
+
className: "modal-info",
|
|
213
|
+
onClose: function onClose() {
|
|
214
|
+
return setOpenPaymethod(null);
|
|
215
|
+
}
|
|
216
|
+
}, !(paymethodSelected !== null && paymethodSelected !== void 0 && (_paymethodSelected$da = paymethodSelected.data) !== null && _paymethodSelected$da !== void 0 && _paymethodSelected$da.publishable) && /*#__PURE__*/_react.default.createElement(_styles.Container, null, /*#__PURE__*/_react.default.createElement("p", null, t('ADD_PUBLISHABLE_KEY', 'Please add a publishable key'))), (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$da2 = paymethodSelected.data) === null || _paymethodSelected$da2 === void 0 ? void 0 : _paymethodSelected$da2.publishable) && (stripeDirectMethods === null || stripeDirectMethods === void 0 ? void 0 : stripeDirectMethods.includes(paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$pa12 = paymethodSelected.paymethod) === null || _paymethodSelected$pa12 === void 0 ? void 0 : _paymethodSelected$pa12.gateway)) && /*#__PURE__*/_react.default.createElement(_StripeElementsForm.StripeElementsForm, {
|
|
217
|
+
methodsPay: methodsPay,
|
|
218
|
+
paymethod: paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$pa13 = paymethodSelected.paymethod) === null || _paymethodSelected$pa13 === void 0 ? void 0 : _paymethodSelected$pa13.gateway,
|
|
219
|
+
businessId: props.businessId,
|
|
220
|
+
cartGroup: cartGroup === null || cartGroup === void 0 ? void 0 : cartGroup.result,
|
|
221
|
+
publicKey: (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$da3 = paymethodSelected.data) === null || _paymethodSelected$da3 === void 0 ? void 0 : _paymethodSelected$da3.publishable) || (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$da4 = paymethodSelected.data) === null || _paymethodSelected$da4 === void 0 ? void 0 : _paymethodSelected$da4.publishable_key),
|
|
222
|
+
handleSource: handlePaymethodDataChange,
|
|
223
|
+
onCancel: function onCancel() {
|
|
224
|
+
return setOpenPaymethod(null);
|
|
225
|
+
},
|
|
226
|
+
handlePlaceOrder: handlePlaceOrder
|
|
227
|
+
})));
|
|
197
228
|
};
|
|
198
229
|
var MultiCartsPaymethodsAndWallets = function MultiCartsPaymethodsAndWallets(props) {
|
|
199
230
|
var multiCartsPaymethodsAndWalletsProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -42,7 +42,7 @@ var mapConfigs = {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
45
|
-
var _Object$values, _cartGroup$result, _paymethodSelected$pa, _cardList$cards, _configs$checkout_mul, _configs$driver_tip_o, _configs$driver_tip_o2, _configs$driver_tip_o3, _configs$multi_busine, _configs$driver_tip_o4, _configs$driver_tip_o5, _loyaltyPlansState$re, _creditPointGeneralPl, _creditPointGeneralPl2, _configs$google_maps_, _customerState$user, _cartGroup$result2, _cartGroup$result3, _validationFields$fie9, _validationFields$fie10, _validationFields$fie11, _configs$multi_busine2, _validationFields$fie12, _validationFields$fie13, _validationFields$fie14, _configs$driver_tip_t, _configs$driver_tip_u, _configs$driver_tip_t2, _openCarts$, _openCarts$2, _configs$multi_busine6, _configs$multi_busine7;
|
|
45
|
+
var _Object$values, _cartGroup$result, _paymethodSelected$pa, _cardList$cards, _configs$checkout_mul, _configs$driver_tip_o, _configs$driver_tip_o2, _configs$driver_tip_o3, _configs$multi_busine, _configs$driver_tip_o4, _configs$driver_tip_o5, _loyaltyPlansState$re, _creditPointPlan$busi, _creditPointPlan$busi2, _loyaltyPlansState$re2, _creditPointGeneralPl, _creditPointGeneralPl2, _configs$google_maps_, _customerState$user, _cartGroup$result2, _cartGroup$result3, _validationFields$fie9, _validationFields$fie10, _validationFields$fie11, _configs$multi_busine2, _validationFields$fie12, _validationFields$fie13, _validationFields$fie14, _configs$driver_tip_t, _configs$driver_tip_u, _configs$driver_tip_t2, _openCarts$, _openCarts$2, _configs$multi_busine6, _configs$multi_busine7;
|
|
46
46
|
var placing = props.placing,
|
|
47
47
|
isCustomerMode = props.isCustomerMode,
|
|
48
48
|
openCarts = props.openCarts,
|
|
@@ -111,7 +111,22 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
111
111
|
var isMultiDriverTips = (configs === null || configs === void 0 ? void 0 : (_configs$checkout_mul = configs.checkout_multi_business_enabled) === null || _configs$checkout_mul === void 0 ? void 0 : _configs$checkout_mul.value) === '1';
|
|
112
112
|
var driverTipsOptions = typeof (configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o = configs.driver_tip_options) === null || _configs$driver_tip_o === void 0 ? void 0 : _configs$driver_tip_o.value) === 'string' ? JSON.parse(configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o2 = configs.driver_tip_options) === null || _configs$driver_tip_o2 === void 0 ? void 0 : _configs$driver_tip_o2.value) || [] : (configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o3 = configs.driver_tip_options) === null || _configs$driver_tip_o3 === void 0 ? void 0 : _configs$driver_tip_o3.value) || [];
|
|
113
113
|
var totalFeeEnabled = (configs === null || configs === void 0 ? void 0 : (_configs$multi_busine = configs.multi_business_checkout_show_combined_delivery_fee) === null || _configs$multi_busine === void 0 ? void 0 : _configs$multi_busine.value) === '1' ? JSON.parse(configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o4 = configs.driver_tip_options) === null || _configs$driver_tip_o4 === void 0 ? void 0 : _configs$driver_tip_o4.value) || [] : (configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o5 = configs.driver_tip_options) === null || _configs$driver_tip_o5 === void 0 ? void 0 : _configs$driver_tip_o5.value) || [];
|
|
114
|
-
var
|
|
114
|
+
var methodsPay = ['global_google_pay', 'global_apple_pay'];
|
|
115
|
+
var creditPointPlan = loyaltyPlansState === null || loyaltyPlansState === void 0 ? void 0 : (_loyaltyPlansState$re = loyaltyPlansState.result) === null || _loyaltyPlansState$re === void 0 ? void 0 : _loyaltyPlansState$re.find(function (loyal) {
|
|
116
|
+
return loyal.type === 'credit_point';
|
|
117
|
+
});
|
|
118
|
+
var businessIds = openCarts.map(function (cart) {
|
|
119
|
+
return cart.business_id;
|
|
120
|
+
});
|
|
121
|
+
var loyalBusinessIds = (_creditPointPlan$busi = creditPointPlan === null || creditPointPlan === void 0 ? void 0 : (_creditPointPlan$busi2 = creditPointPlan.businesses) === null || _creditPointPlan$busi2 === void 0 ? void 0 : _creditPointPlan$busi2.filter(function (b) {
|
|
122
|
+
return b.accumulates;
|
|
123
|
+
}).map(function (item) {
|
|
124
|
+
return item.business_id;
|
|
125
|
+
})) !== null && _creditPointPlan$busi !== void 0 ? _creditPointPlan$busi : [];
|
|
126
|
+
var creditPointPlanOnBusiness = businessIds.every(function (bid) {
|
|
127
|
+
return loyalBusinessIds.includes(bid);
|
|
128
|
+
}) && creditPointPlan;
|
|
129
|
+
var creditPointGeneralPlan = loyaltyPlansState === null || loyaltyPlansState === void 0 ? void 0 : (_loyaltyPlansState$re2 = loyaltyPlansState.result) === null || _loyaltyPlansState$re2 === void 0 ? void 0 : _loyaltyPlansState$re2.find(function (loyal) {
|
|
115
130
|
return loyal.type === 'credit_point';
|
|
116
131
|
});
|
|
117
132
|
var loyalBusinessAvailable = (_creditPointGeneralPl = creditPointGeneralPlan === null || creditPointGeneralPlan === void 0 ? void 0 : (_creditPointGeneralPl2 = creditPointGeneralPlan.businesses) === null || _creditPointGeneralPl2 === void 0 ? void 0 : _creditPointGeneralPl2.filter(function (b) {
|
|
@@ -220,6 +235,16 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
220
235
|
showToast(_orderingComponentsExternal.ToastType.Error, t(walletState.error, (_walletState$error = walletState.error) === null || _walletState$error === void 0 ? void 0 : (_walletState$error$ = _walletState$error[0]) === null || _walletState$error$ === void 0 ? void 0 : _walletState$error$.replace(/_/g, ' ')));
|
|
221
236
|
}
|
|
222
237
|
}, [walletState.error]);
|
|
238
|
+
(0, _react.useEffect)(function () {
|
|
239
|
+
var _paymethodSelected$pa2;
|
|
240
|
+
if (methodsPay.includes(paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$pa2 = paymethodSelected.paymethod) === null || _paymethodSelected$pa2 === void 0 ? void 0 : _paymethodSelected$pa2.gateway) && typeof (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.paymethod_data) === 'string') {
|
|
241
|
+
var _JSON$parse;
|
|
242
|
+
var hasSource = (_JSON$parse = JSON.parse(paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.paymethod_data)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.source_id;
|
|
243
|
+
if (hasSource) {
|
|
244
|
+
handlePlaceOrder();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}, [paymethodSelected]);
|
|
223
248
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !(cartGroup !== null && cartGroup !== void 0 && cartGroup.loading) && openCarts.length === 0 || !cartUuid ? /*#__PURE__*/_react.default.createElement(_NotFoundSource.NotFoundSource, {
|
|
224
249
|
content: t('NOT_FOUND_CARTS', 'Sorry, You don\'t seem to have any carts.'),
|
|
225
250
|
btnTitle: t('SEARCH_REDIRECT', 'Go to Businesses'),
|
|
@@ -257,7 +282,9 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
257
282
|
handlePaymethodDataChange: handlePaymethodDataChange,
|
|
258
283
|
cartUuid: cartUuid,
|
|
259
284
|
isCustomerMode: isCustomerMode,
|
|
260
|
-
|
|
285
|
+
cartGroup: cartGroup,
|
|
286
|
+
setCardList: setCardList,
|
|
287
|
+
handlePlaceOrder: handlePlaceOrder
|
|
261
288
|
})), (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie9 = validationFields.fields) === null || _validationFields$fie9 === void 0 ? void 0 : (_validationFields$fie10 = _validationFields$fie9.checkout) === null || _validationFields$fie10 === void 0 ? void 0 : (_validationFields$fie11 = _validationFields$fie10.coupon) === null || _validationFields$fie11 === void 0 ? void 0 : _validationFields$fie11.enabled) && openCarts.every(function (cart) {
|
|
262
289
|
return cart.business_id && cart.status !== 2;
|
|
263
290
|
}) && (configs === null || configs === void 0 ? void 0 : (_configs$multi_busine2 = configs.multi_business_checkout_coupon_input_style) === null || _configs$multi_busine2 === void 0 ? void 0 : _configs$multi_busine2.value) === 'group' && /*#__PURE__*/_react.default.createElement(_styles.DriverTipContainer, null, /*#__PURE__*/_react.default.createElement("h1", null, t('DISCOUNT_COUPON', 'Discount coupon')), /*#__PURE__*/_react.default.createElement(_styles.CouponContainer, null, /*#__PURE__*/_react.default.createElement(_CouponControl.CouponControl, {
|
|
@@ -51,10 +51,8 @@ var OrderEta = function OrderEta(props) {
|
|
|
51
51
|
}
|
|
52
52
|
_estimatedTime = _moment.default.utc(_delivery).add(totalEta, 'minutes');
|
|
53
53
|
} else {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (order !== null && order !== void 0 && order.delivered_in) {
|
|
57
|
-
_estimatedTime = _moment.default.utc(_delivery).add(order === null || order === void 0 ? void 0 : order.delivered_in, 'minutes');
|
|
54
|
+
var _etaTime = order !== null && order !== void 0 && order.delivered_in ? (order === null || order === void 0 ? void 0 : order.delivered_in) + (order === null || order === void 0 ? void 0 : order.eta_time) : order === null || order === void 0 ? void 0 : order.eta_time;
|
|
55
|
+
_estimatedTime = _moment.default.utc(_delivery).add(_etaTime, 'minutes');
|
|
58
56
|
}
|
|
59
57
|
_estimatedTime = outputFormat ? (0, _moment.default)(_estimatedTime).local().format(outputFormat) : parseDate(_estimatedTime, {
|
|
60
58
|
utc: false
|
|
@@ -97,7 +97,7 @@ var paypalBtnStyle = {
|
|
|
97
97
|
size: 'responsive'
|
|
98
98
|
};
|
|
99
99
|
var PaymentOptionsUI = function PaymentOptionsUI(props) {
|
|
100
|
-
var _props$beforeElements, _props$beforeComponen, _paymethodsList$error, _cart$balance, _paymethodSelected$da2, _isOpenMethod$paymeth2, _isOpenMethod$paymeth3, _isOpenMethod$paymeth4, _isOpenMethod$paymeth5, _isOpenMethod$paymeth6, _paymethodData$card, _paymethodData$card2, _paymethodData$card3, _isOpenMethod$paymeth7, _isOpenMethod$paymeth8, _isOpenMethod$paymeth9, _isOpenMethod$paymeth10, _isOpenMethod$paymeth11, _cart$balance2, _isOpenMethod$paymeth12, _isOpenMethod$paymeth13, _isOpenMethod$paymeth14, _isOpenMethod$paymeth15, _isOpenMethod$paymeth16, _isOpenMethod$paymeth17, _isOpenMethod$paymeth18, _isOpenMethod$paymeth19, _isOpenMethod$paymeth20, _isOpenMethod$paymeth21, _isOpenMethod$paymeth22, _isOpenMethod$paymeth23, _isOpenMethod$paymeth24, _isOpenMethod$paymeth25, _isOpenMethod$paymeth26, _isOpenMethod$paymeth27, _isOpenMethod$paymeth28, _isOpenMethod$paymeth29, _isOpenMethod$paymeth30, _isOpenMethod$paymeth31, _isOpenMethod$paymeth32, _isOpenMethod$paymeth33, _props$afterComponent, _props$afterElements;
|
|
100
|
+
var _list$filter, _props$beforeElements, _props$beforeComponen, _paymethodsList$error, _cart$balance, _paymethodSelected$da2, _isOpenMethod$paymeth2, _isOpenMethod$paymeth3, _isOpenMethod$paymeth4, _isOpenMethod$paymeth5, _isOpenMethod$paymeth6, _paymethodData$card, _paymethodData$card2, _paymethodData$card3, _isOpenMethod$paymeth7, _isOpenMethod$paymeth8, _isOpenMethod$paymeth9, _isOpenMethod$paymeth10, _isOpenMethod$paymeth11, _cart$balance2, _isOpenMethod$paymeth12, _isOpenMethod$paymeth13, _isOpenMethod$paymeth14, _isOpenMethod$paymeth15, _isOpenMethod$paymeth16, _isOpenMethod$paymeth17, _isOpenMethod$paymeth18, _isOpenMethod$paymeth19, _isOpenMethod$paymeth20, _isOpenMethod$paymeth21, _isOpenMethod$paymeth22, _isOpenMethod$paymeth23, _isOpenMethod$paymeth24, _isOpenMethod$paymeth25, _isOpenMethod$paymeth26, _isOpenMethod$paymeth27, _isOpenMethod$paymeth28, _isOpenMethod$paymeth29, _isOpenMethod$paymeth30, _isOpenMethod$paymeth31, _isOpenMethod$paymeth32, _isOpenMethod$paymeth33, _props$afterComponent, _props$afterElements;
|
|
101
101
|
var cart = props.cart,
|
|
102
102
|
errorCash = props.errorCash,
|
|
103
103
|
isLoading = props.isLoading,
|
|
@@ -139,11 +139,14 @@ var PaymentOptionsUI = function PaymentOptionsUI(props) {
|
|
|
139
139
|
var methodsPay = ['google_pay', 'apple_pay'];
|
|
140
140
|
var stripeDirectMethods = ['stripe_direct'].concat(methodsPay);
|
|
141
141
|
var includeKioskPaymethods = ['cash', 'card_delivery'];
|
|
142
|
+
var multiCheckoutMethods = ['global_google_pay', 'global_apple_pay'];
|
|
142
143
|
var list = paymethodsList ? paymethodsList === null || paymethodsList === void 0 ? void 0 : paymethodsList.paymethods : paymethods === null || paymethods === void 0 ? void 0 : paymethods.map(function (pay) {
|
|
143
144
|
return pay.paymethod;
|
|
144
145
|
});
|
|
145
146
|
var popupMethods = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal', 'square', 'google_pay', 'apple_pay'];
|
|
146
|
-
var supportedMethods = list === null || list === void 0 ? void 0 : list.filter(function (p) {
|
|
147
|
+
var supportedMethods = list === null || list === void 0 ? void 0 : (_list$filter = list.filter(function (p) {
|
|
148
|
+
return !multiCheckoutMethods.includes(p.gateway);
|
|
149
|
+
})) === null || _list$filter === void 0 ? void 0 : _list$filter.filter(function (p) {
|
|
147
150
|
return useKioskApp ? includeKioskPaymethods.includes(p.gateway) : p;
|
|
148
151
|
});
|
|
149
152
|
var handlePaymentMethodClick = function handlePaymentMethodClick(paymethod) {
|
|
@@ -198,7 +201,7 @@ var PaymentOptionsUI = function PaymentOptionsUI(props) {
|
|
|
198
201
|
if (methodsPay.includes(paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.gateway) && paymethodData !== null && paymethodData !== void 0 && paymethodData.id && paymethodSelected !== null && paymethodSelected !== void 0 && (_paymethodSelected$da = paymethodSelected.data) !== null && _paymethodSelected$da !== void 0 && _paymethodSelected$da.card) {
|
|
199
202
|
handlePlaceOrder();
|
|
200
203
|
}
|
|
201
|
-
}, [paymethodData, paymethodSelected]);
|
|
204
|
+
}, [JSON.stringify(paymethodData), paymethodSelected]);
|
|
202
205
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (_props$beforeElements = props.beforeElements) === null || _props$beforeElements === void 0 ? void 0 : _props$beforeElements.map(function (BeforeElement, i) {
|
|
203
206
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
204
207
|
key: i
|
|
@@ -215,9 +218,9 @@ var PaymentOptionsUI = function PaymentOptionsUI(props) {
|
|
|
215
218
|
var _isOpenMethod$paymeth;
|
|
216
219
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
217
220
|
key: paymethod.id
|
|
218
|
-
}, (!isCustomerMode || isCustomerMode && (paymethod.gateway === 'card_delivery' || paymethod.gateway === 'cash')) && /*#__PURE__*/_react.default.createElement(_styles.PayCard, {
|
|
221
|
+
}, (!isCustomerMode && paymethod.gateway || isCustomerMode && (paymethod.gateway === 'card_delivery' || paymethod.gateway === 'cash')) && /*#__PURE__*/_react.default.createElement(_styles.PayCard, {
|
|
219
222
|
isDisabled: isDisabled,
|
|
220
|
-
className: "
|
|
223
|
+
className: "".concat(((paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.id) || (isOpenMethod === null || isOpenMethod === void 0 ? void 0 : (_isOpenMethod$paymeth = isOpenMethod.paymethod) === null || _isOpenMethod$paymeth === void 0 ? void 0 : _isOpenMethod$paymeth.id)) === paymethod.id ? 'active' : ''),
|
|
221
224
|
onClick: function onClick() {
|
|
222
225
|
return handlePaymentMethodClick(paymethod);
|
|
223
226
|
}
|
|
@@ -37,7 +37,8 @@ var StripeElementsFormUI = function StripeElementsFormUI(props) {
|
|
|
37
37
|
paymethod = props.paymethod,
|
|
38
38
|
cart = props.cart,
|
|
39
39
|
handlePlaceOrder = props.handlePlaceOrder,
|
|
40
|
-
methodsPay = props.methodsPay
|
|
40
|
+
methodsPay = props.methodsPay,
|
|
41
|
+
cartGroup = props.cartGroup;
|
|
41
42
|
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
42
43
|
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
43
44
|
t = _useLanguage2[1];
|
|
@@ -53,6 +54,7 @@ var StripeElementsFormUI = function StripeElementsFormUI(props) {
|
|
|
53
54
|
stripe: (0, _pure.loadStripe)(publicKey)
|
|
54
55
|
}, methodsPay !== null && methodsPay !== void 0 && methodsPay.includes(paymethod) ? /*#__PURE__*/_react.default.createElement(_StripeMethodForm.StripeMethodForm, {
|
|
55
56
|
cart: cart,
|
|
57
|
+
cartGroup: cartGroup,
|
|
56
58
|
handleSource: handleSource,
|
|
57
59
|
onNewCard: onNewCard,
|
|
58
60
|
toSave: toSave,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import { PaymentRequestButtonElement, useStripe } from '@stripe/react-stripe-js'
|
|
3
|
-
import { CardForm as CardFormController, useLanguage } from 'ordering-components-external'
|
|
3
|
+
import { CardForm as CardFormController, useConfig, useLanguage } from 'ordering-components-external'
|
|
4
4
|
import Skeleton from 'react-loading-skeleton'
|
|
5
5
|
import { Container } from './styles'
|
|
6
6
|
export const StripeMethodFormUI = (props) => {
|
|
@@ -8,22 +8,33 @@ export const StripeMethodFormUI = (props) => {
|
|
|
8
8
|
cart,
|
|
9
9
|
handleSource,
|
|
10
10
|
handleCancel,
|
|
11
|
-
paymethod
|
|
11
|
+
paymethod,
|
|
12
|
+
cartGroup
|
|
12
13
|
} = props
|
|
13
14
|
|
|
14
15
|
const [, t] = useLanguage()
|
|
15
16
|
const stripe = useStripe()
|
|
17
|
+
const [{ configs }] = useConfig()
|
|
16
18
|
const [paymentRequest, setPaymentRequest] = useState(null)
|
|
17
19
|
const [methodUnavailable, setMethodUnavailable] = useState(false)
|
|
18
20
|
|
|
21
|
+
const googlePayMethods = ['google_pay', 'global_google_pay']
|
|
22
|
+
|
|
19
23
|
useEffect(() => {
|
|
20
24
|
if (stripe) {
|
|
25
|
+
let cartNames = ''
|
|
26
|
+
if (cartGroup) {
|
|
27
|
+
// eslint-disable-next-line no-unused-expressions
|
|
28
|
+
cartGroup?.carts.map((cart, i) => (
|
|
29
|
+
cartNames = `${cart?.business?.name} ${i !== cartNames?.carts?.length && ', '}`
|
|
30
|
+
))
|
|
31
|
+
}
|
|
21
32
|
const pr = stripe.paymentRequest({
|
|
22
33
|
country: 'US',
|
|
23
|
-
currency: 'usd',
|
|
34
|
+
currency: configs?.stripe_currency?.value?.toLowerCase?.() || 'usd',
|
|
24
35
|
total: {
|
|
25
|
-
label: cart?.business?.name,
|
|
26
|
-
amount: Math.floor((cart?.balance || cart?.total) * 100)
|
|
36
|
+
label: cartNames || cart?.business?.name,
|
|
37
|
+
amount: Math.floor((cartGroup?.balance || cartGroup?.total || cart?.balance || cart?.total) * 100)
|
|
27
38
|
},
|
|
28
39
|
requestPayerName: true,
|
|
29
40
|
requestPayerEmail: true
|
|
@@ -36,9 +47,7 @@ export const StripeMethodFormUI = (props) => {
|
|
|
36
47
|
}
|
|
37
48
|
})
|
|
38
49
|
pr.on('paymentmethod', async (e) => {
|
|
39
|
-
|
|
40
|
-
handleCancel()
|
|
41
|
-
handleSource({
|
|
50
|
+
const data = {
|
|
42
51
|
...e?.paymentMethod?.card,
|
|
43
52
|
id: e.paymentMethod.id,
|
|
44
53
|
type: e.paymentMethod.type,
|
|
@@ -47,7 +56,10 @@ export const StripeMethodFormUI = (props) => {
|
|
|
47
56
|
brand: e.paymentMethod.card.brand,
|
|
48
57
|
last4: e.paymentMethod.card.last4
|
|
49
58
|
}
|
|
50
|
-
}
|
|
59
|
+
}
|
|
60
|
+
e.complete('success')
|
|
61
|
+
handleCancel()
|
|
62
|
+
handleSource(cartGroup ? JSON.stringify(data) : data)
|
|
51
63
|
})
|
|
52
64
|
}
|
|
53
65
|
}, [stripe])
|
|
@@ -55,7 +67,7 @@ export const StripeMethodFormUI = (props) => {
|
|
|
55
67
|
return (
|
|
56
68
|
<Container>
|
|
57
69
|
{methodUnavailable ? (
|
|
58
|
-
<h2>{paymethod
|
|
70
|
+
<h2>{googlePayMethods.includes(paymethod) ? t('GOOGLE_PAY_UNAVAILABLE', 'Google pay unavailable') : t('APPLE_PAY_UNAVAILABLE', 'Apple pay unavailable')}</h2>
|
|
59
71
|
) : (
|
|
60
72
|
<>
|
|
61
73
|
{paymentRequest ? (
|
|
@@ -32,7 +32,7 @@ export const CitiesControl = (props) => {
|
|
|
32
32
|
<Skeleton height={40} count={3} style={{ marginBottom: '10px' }} />
|
|
33
33
|
) : (
|
|
34
34
|
<>
|
|
35
|
-
{cities?.map(city => (
|
|
35
|
+
{cities?.map(city => city?.enabled && (
|
|
36
36
|
<CityItem key={city?.id} onClick={() => setCityState(city?.id === cityState ? null : city?.id)}>
|
|
37
37
|
<span className='radio'>
|
|
38
38
|
{city?.id === cityState
|
|
@@ -115,7 +115,7 @@ export const OriginalHomeHero = (props) => {
|
|
|
115
115
|
<ContentWrapper>
|
|
116
116
|
{windowSize.width < 576 && !isChew && (
|
|
117
117
|
<LogoWrapper>
|
|
118
|
-
<img alt='Logotype' src={
|
|
118
|
+
<img alt='Logotype' src={theme?.images?.logos?.logotypeInvert} loading='lazy' />
|
|
119
119
|
</LogoWrapper>
|
|
120
120
|
)}
|
|
121
121
|
<HeroContent>
|